Happy FOSS

Opensource, Technology, Programming & Computer Science

Port forwarding 80 to Tomcat port

For security reason Tomcat doesnt run on port 80.

The simple trick is to write an iptable rule to perform the port forwarding request arriving at port 80 to Tomcat port (say 8080).

Write the following content to the a shell script file say tomcat_firewall.sh

/sbin/iptables -A FORWARD -p tcp –destination-port 80 -j ACCEPT

/sbin/iptables -t nat -A PREROUTING -j REDIRECT -p tcp –destination-port 80 –to-ports 8080

And add this script as root in /etc/rc.local as shown below, this ensures the setting is done whenever the server startsup.

su – root “/path-to-the-file/tomcat_firewall.sh

August 26, 2008 Posted by | Internet, Linux | | Leave a comment