Server device, if a domain name is requested, the port is pointing to port 80 by default, but more of our services are posted in tomcat and more 8080 ports are used
As we all know, the server installation Nginx can do port mapping, and then set the service to the desired place.
Job requirements, to provide a scenario that does not need to install Nginx, the 80 port mapping to 8080 ports, so as to reach the direct access to the server to reach the 8080 port service.
Login with Tomcat user, start Tomcat, discover that Tomcat cannot start, error: Lifecycleexception:protocol handler initialization failed: Java.net.BindException:Permission denied <null>:80
By Netstat-lnp|grep 80 found no program occupies 80 ports
The reason is that only the root user can access ports below 1024.
Workaround:
Change the port in Server.xml to 8080 and then jump 80 ports to 8080 ports via iptables
Port mapping via iptables, map port 80 to 8080
Iptables-t nat-a prerouting-p tcp--dport 80-j REDIRECT--to-port 8080
BUG: If this happens, the server needs to be restarted, and the port mapping needs to be re-added, from the new execution of the above command.
If the personal server is used, and the configuration is not very high, do not want to install Nginx, the use of this method can solve the problem you encountered.
Server 80 port mapped to port 8080