Ngixn负载均衡器不断更改原始URL以加载平衡URL

时间:2015-09-06 04:17:28

标签: nginx url-rewriting load-balancing

我遇到了Nginx Load Balancer的烦人问题,请参阅以下配置:

http {
    server {
        listen       3333;
        server_name  localhost;
        location / {
                 proxy_pass http://node;
                 proxy_redirect off;
        }
    }
    server {
        listen       7777;
        server_name  localhost;
        location / {
                 proxy_pass http://auth;
                 proxy_redirect off;
        }
    }
    upstream node {
        server localhost:3000;
        server localhost:3001;
    }
    upstream auth {
        server localhost:8079;
        server localhost:8080;
    }
}

所以我想要的是提供两个负载均衡器,一个是将端口3333发送到内部端口3000,3001,第二个是将请求发送到7777到内部8079和8000.

当我测试此设置时,我注意到http://localhost:3333的所有请求都运行良好,地址栏中的URL始终是这个,但当我访问http://localhsot:7777时,我注意到所有请求被重定向到内部网址http://localhost:8080http://localhost:8079

我不知道为什么对于负载平衡有两种不同的影响,我只想让所有访问者只看到http://localhost:3333http://localhost:7777,他们永远不会看到内部端口8080或8079。

但是为什么端口3000和3001的节点服务器工作正常,而端口8080和8079的java服务器没有进行url重写,但只进行重定向?

如果您看到配置,它们完全相同。 感谢。

0 个答案:

没有答案