I want to execute my web app as http://localhost
.
if you are using eclipse and modifying server.xml doesn't work for you then try following article.. they have steps to modify port if you are using IDE like eclipse.
Running the command below worked with. Tried changing server.xml
and the conf file but both didn't work.
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
Here are the steps:
--> Follow the path: {tomcat directory>/conf -->Find this line:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
change portnumber from "8080" to "80".
--> Save the file.
--> Restart the server :)
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
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 have port="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.
As previous answers didn't work well (it was good, but not enough) for me on a 14.04 Ubuntu Server, I mention these recommendations (this is a quote).
Edit: note that as @jason-faust mentioned it in the comments, on 14.04, the authbind
package that ships with it does support IPv6 now, so the prefer IPv4 thing isn't needed any longer.
1) Install authbind
2) Make port 80 available to authbind (you need to be root):
touch /etc/authbind/byport/80
chmod 500 /etc/authbind/byport/80
chown tomcat7 /etc/authbind/byport/80
3) Make IPv4 the default (authbind does not currently support IPv6).
To do so, create the file TOMCAT/bin/setenv.sh with the following content:
CATALINA_OPTS="-Djava.net.preferIPv4Stack=true"
4) Change /usr/share/tomcat7/bin/startup.sh
exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@"
# OLD: exec "$PRGDIR"/"$EXECUTABLE" start "$@"
If you already got a setenv.sh
file in /usr/share/tomcat7/bin
with CATALINA_OPTS
, you have to use :
export CATALINA_OPTS="$CATALINA_OPTS -Djava.net.preferIPv4Stack=true"
Now you can change the port to 80
as told in other answers.