Tuesday, May 9, 2017

Change port 8080 to 80 in Tomcat

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.
If you don't find setenv.sh try to create it.

http://stackoverflow.com/questions/4756039/how-to-change-the-port-of-tomcat-from-8080-to-80