Configure iptables a simple way to transfer port 80 to 8080

  • 2020-05-14 05:47:24
  • OfStack

tomcat was deployed below Linux, and we started with a non-root user for security purposes, but we could not access port 80 directly during domain name binding. As we all know, under unix, non-root users cannot listen to port Numbers above 1024, so the tomcat server cannot be bound under port 80. So you need to use linux's port forwarding mechanism to transfer all service requests to port 80 to port 8080.

Run 1 under the root account:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

Note: an online friend's command dport is always preceded by a --, which usually results in an error. In addition, if the firewall is restarted, the command will be invalidated.

You can save the rule to iptables by using the following command:

service iptables save


Related articles: