Run Tomcat7 on Port 80
You may need to run Tomcat on port 80 for many reasons. It is possible to accomplish this in three steps.
First step is move 8080 to port 80.Find your server.xml file for Tomcat. It is probably under /etc/tomcat/server.xml but still
you can find it by using:
$ locate server.xml
/etc/tomcat7/server.xml
Open server.xml file with an avaliable text editor (I will use nano).
$ sudo nano /etc/tomcat7/server.xml
Find the part where port is defined as 8080 and change it to 80.
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" />
Close the file by saving it. If you run tomcat now it will complain about some authentication errors. It happens because we are trying to run Tomcat under 1023 ports. So the next step is enable authbind for tomcat. If you run Tomcat on port numbers that are all higher than 1023, then you do not need authbind. It is used for binding Tomcat to lower port numbers. Open /etc/default/tomcat with your text editor.
$ sudo nano /etc/default/tomcat7
Switch authbind=no to authbind=yes which is located at the end of file.
# NOTE: authbind works only with IPv4. Do not enable it when using IPv6.
# (yes/no, default: no)
AUTHBIND=yes
The last step is disabling IPv6. You can see the warning just before authbind line saying that “NOTE: authbind works only with IPv4. Do not enable it when using IPv6.”. Open /etc/sysctl.conf with your text editor.
$ sudo nano /etc/sysctl.conf
And add these three lines to end of the file.
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Save the file and close it. To make sure IPv6 is disabled run
sudo sysctl -p
and you will see
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
After that, if you run:
$ cat /proc/sys/net/ipv6/conf/all/disable_ipv6
It will report: 1
Now it is ready to run on port 80. Start your tomcat with
$ sudo service tomcat7 start
If you look at your catalina.out logs it will be written in there as
Mar 21, 2015 10:02:44 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-80"]
Now you can access your services directly without any port like
example.com/Services/