Server 80 port mapped to port 8080

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.