How to change the port of Tomcat from 8080 to 80?
1) Go to conf
folder in tomcat installation directory
e.g. C:\Tomcat 6.0\conf\
2) Edit following tag in server.xml
file
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
3) Change the port=8080
value to port=80
4) Save file.
5) Stop your Tomcat and restart it.
Ubuntu 14.04 LTS, in Amazon EC2. The following steps resolved this issue for me:
1. Edit server.xml and change port="8080" to "80"
sudo vi /var/lib/tomcat7/conf/server.xml
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
2. Edit tomcat7 file (if the file is not created then you need to create it)
sudo vi /etc/default/tomcat7
uncomment and change #AUTHBIND=no to yes
3. Install authbind
sudo apt-get install authbind
4. Run the following commands to provide tomcat7 read+execute on port 80.
sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat7 /etc/authbind/byport/80
5. Restart tomcat:
sudo /etc/init.d/tomcat7 restart
On a Linux Debian-based (so Ubuntu included) you have also to go to /etc/default/tomcat7
, uncomment the #AUTHBIND=no
line and set its value to 'yes', in order to let the server bind on a privileged port.
On Ubuntu and Debian systems, there are several steps needed:
In server.xml, change the line
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
to haveport="80"
.-
Install the recommended (not required) authbind package, with a command like:
sudo apt-get install authbind
-
Enable authbind in the server.xml file (in either
/etc/tomcat6
or/etc/tomcat7
) by uncommenting and setting the line like:AUTHBIND=yes
All three steps are needed.
I tried changing the port from 8080
to 80
in the server.xml
but it didn't work for me. Then I found alternative, update the iptables
which i'm sure there is an impact on performance.
I use the following commands:
sudo /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo /sbin/service iptables save
http://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html#port80