我使用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:端口进入acount)实际行为: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;
               }
}

任何帮助将不胜感激 .