Can nginx also proxy ports other than 80 and 443?

Yes, Nginx can be configured to proxy traffic on any port. Nginx itself does not limit the ports it can listen on and proxy to, except for those ports that require operating system permissions (usually ports below 1024).

In the Nginx configuration file, you can specify the listening port and the target address and port to be proxied. For example:

server {
    listen 8080;

    location / {
        proxy_pass http://localhost:2345;
    }
}

This configuration will make Nginx listen on port 8080, and then proxy all requests to port 8080 to the local port 2345. In this way, external clients can indirectly access services running on port 2345 http://yourserver.com:8080by .

As long as you have permission and the port is not occupied by other services, you can use Nginx to proxy traffic on any port.

Guess you like

Origin blog.csdn.net/m0_57236802/article/details/131301973