Nginx无法代理端口

时间:2018-06-20 06:45:37

标签: azure nginx openam nginx-reverse-proxy

我正在使用Nginx作为负载平衡器。它能够将请求路由到指定的主机地址,但不能路由到上游模块中提到的端口。它总是将其发送到默认端口。

我尝试了多种方法来修改proxy_set_header Hostproxy_set_header X-Forwarded-Forproxy_set_header X-Real-IPproxy_set_header X-Forwarded-Protoproxy_set_header Referer等。但是似乎没有任何效果。

我在Azure中安装了Nginx服务器,并尝试访问同一虚拟网络中的VM。

预期的行为: http://localhost/sites -----> http://zzz:9081/sites(应将IP:Port纳入帐户) 实际行为: http://localhost/sites -----> http://zzz/sites(获取IP,但端口为80 /默认监听端口)。

  upstream alb {
      ip_hash;
      server zzz:9081;
      server zzz:9080;
    }


     server {
            listen       80;
            server_name  localhost;
            # root         /usr/share/nginx/html;


            location /sites {
               proxy_pass http://alb/sites;
               proxy_set_header X-Real-IP $remote_addr;
               }
}

任何帮助将不胜感激。

0 个答案:

没有答案
相关问题