Home > Linux > Configuring CentOS 5.5 Firewall for Apache

Configuring CentOS 5.5 Firewall for Apache

More of a note to myself…

Lately, I’ve been thinking about getting into the cloud computing platform. However, that does mean I would be starting off from ‘scratch’ with AMI’s or Linux distros, especially minimal distros that run in a server environment. (No GUI tools!)

I just installed a very minimal CentOS 5.5 distro with sshd and Apache. (I also installed Nano, a text editor.) I had some difficulties in getting the iptables firewall to work with Apache. Here’s the solution. I hope this doesn’t break standard security conventions…

$ cd /etc/sysconfig
$ nano iptables

Add in this line
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

AFTER:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

The final output should look like:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

I added in this line after port 22, because it is already opened in the default IPTABLES configuration to allow SSH shell access. Port 80 is needed for HTTPD access.

Exit and save the iptables file. Then type in:
$ service iptables restart
$ service httpd restart

Now, you should be able to view Apache content running on the CentOS 5.5 server. Next up on my queue? Adding in VSFTPD and PHP support. How fun! :)

Categories: Linux Tags: , ,