nginx通过 proxy_pass 设置反向代理,隐藏端口号

nginx配置修改,通过 proxy_pass 设置反向代理,监听域名(IP)转发到指定端口。

server
    {
        listen 80;
        server_name www.xxx.com;

        server_name_in_redirect off;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
        
        location / {
            proxy_pass http://www.xxx.com:8978;
        }
    }

 

你可能感兴趣的:(服务器)