Difference between revisions of "Howto Block or Open HTTP/HTTPs Ports IPTables"
(Created page with "==Howto Block or Open Port HTTP(80)/HTTPS(443) with IPTables== Just installed your web server application, but you can not view the site from an outside source. Have you all...") |
(No difference)
|
Revision as of 17:03, 11 April 2014
Howto Block or Open Port HTTP(80)/HTTPS(443) with IPTables
Just installed your web server application, but you can not view the site from an outside source. Have you allowed the traffic to view your web server? By default, only SSHD is enabled.
Apache webserver uses the TCP protocol to transfer information/data between server and browser. The default Iptables configuration does not allow inbound access to the HTTP (80) and HTTPS (443) ports used by the web server. This post explains how to allow inbound and outbound access to web services under Linux.
Edit the Iptables file
You can always edit your iptables file at /etc/sysconfig/iptables in Centos. Add the following lines, ensuring that they appear before the final LOG and DROP lines for the RH-Firewall-1-INPUT chain to open port 80 and 443:
vim /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
Now restart iptables
/etc/init.d/iptables restart
Add via Command Line
/sbin/iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT /sbin/iptables -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT
Save and close the file. Please note that under Red Hat enterprise Linux (RHEL) / CentOS / Fedora Linux you can use following commands to save and restore firewall rules.
/etc/init.d/iptables save