Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a Tomcat application running on my Linux machine on port 8080 (www.myapplication.com:8080/myapps).

I want to redirect the Tomcat port :8080 to the default HTTP port of :80 so that the application can be accesed without a port number (www.myapplication.com/myapps).

How can I do that on Linux?

share|improve this question

migrated from stackoverflow.com Feb 15 '12 at 5:48

This question came from our site for professional and enthusiast programmers.

Why not just update tomcat configuration to listen on 80 instead of 8080? –  Sergey Feb 15 '12 at 4:41
Off-topic for SO; belongs on Server Fault –  Ex Umbris Feb 15 '12 at 4:42
...or even askubuntu.com –  php-coder Feb 15 '12 at 4:45

4 Answers 4

You could use iptables to redirect port 80 to 8080.

This is useful if your application is started by an unprivileged user instead of root.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080


share|improve this answer

There so many ways to achieve this, but first which comes to my mind is to use nginx: http://serverfault.com/questions/180800/how-to-permanently-redirect-port-8080-url-to-port-80-using-nginx

Another one is to use iptables: http://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/

share|improve this answer
Thanks php-coder...Its sloved my problem..I executed on command and its worked for me...:) –  user1206852 Feb 15 '12 at 5:25

You should never face the Tomcat or any other Java application server to the external world. The best practice is to install Apache HTTPD and use it a reverse proxy to wrap Tomcat or JBoss.

I recommend to do the following.

  1. Install httpd:

    yum install httpd
  2. Create file

    with the following content:

  3. If the application resides in the root than the configuration will be the following:

  4. Restart httpd:

    service httpd restart

The instructions above are provided for RedHat-family linux. They may differ for other ones.

share|improve this answer
Why not let java face the world? –  Ondra Žižka Sep 19 '13 at 0:05

first you should change server.xml file, change "Connector port="8080" " to "80". the file may be at /etc/tomcat6, or you could use "locate server.xml" to find it.

second you should change the default tomcat6 configure file, in my system (debian squeeze) is /etc/default/tomcat6, add the line: AUTHBIND=yes.

restart your tomcat.

then you can use www.myapplication.com/myapps to access your app.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.