Method of adding 80 ports to normal users of Linux system

Source: Internet
Author: User

In a Linux system, only the root user can bind to ports under 1024 by default, and ordinary users need to bind ports below 1024, the basic method is to use the Nginx agent forwarding or operating system iptables port forwarding two ways, This article will take Tomcat as an example, run Tomcat directly with a normal user, and have the Tomcat program bind to port 80 or forward proxy to Tomcat's 8080 port.

To make the machine 80 port to the client method ask, you can refer to the following ways:

Iptables Port Forwarding Method
Nginx Agent Mode
Setcap Way
1, Iptables Way

RHEL 7

#firewall-cmd–permanent–add-forward-port=port=80:proto=tcp:toport=8080

RHEL 7 Previous version

#iptables-T nat-a prerouting-p tcp–dport 80-j redirect–to-port 8080

2. Install Nginx and forward 80 ports to 8080

Listen 80;

Location/{
Proxy_pass http://localhost:8080;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
}

3, Setcap Way

#setcap ' Cap_net_bind_service=ep '/usr/local/jdk1.8.0/jre/bin/java

/usr/local/jdk1.8.0/jre/bin/java the Java Environment Program that is run for Tomcat, or the absolute path to another program if it is another program.

In addition: EP for permanent entry into force

Query man 7 capabilities through man help

Cap_net_bind_service
Bind a socket to Internet domain privileged ports (port numbers less than 1024).

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.