- Make Tomcat listen to port 80.
- Forward the traffic of port 80 to port 8080.
A. Make Tomcat listen to port 80.
1. Change listening port from 8080 to 80.[root@test ~]# vi $CATALINA_HOME/conf/server.xml
...
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
...
2. Restart Tomcat to listen port 80.
[root@test ~]# $CATALINA_HOME/bin/shutdown.sh
...
[root@test ~]# $CATALINA_HOME/bin/startup.sh
...
Tomcat started.
B. Forward traffic of port 80 to port 8080.
Create a forward rule for both runtime and permanent on Enterprise Linux 7.[root@test ~]# firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8080
success
[root@test ~]# firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8080 --permanent
success
The above commands create a rule on firewall to forward all incoming packets of port 80 to port 8080 by firewall-cmd, which also means that making 80 an alias port of 8080.
The forward or alias technique could make the web server more flexible if there's a chance to build a true http service on port 80 underlyingly in the future.
For more firewall distinctions, you may refer to this post:
How to Open Ports on IPTABLES and Survive across Reboots on Enterprise Linux 6 and 7