NGINX Configuration :



我是Nginx的新手,我正在尝试加载平衡我们的ERP Web服务器。我有3个Web服务器在端口80上运行,由WebSphere提供动力,这对我来说是一个黑匣子:

* web01.example.com/path/apphtml
* web02.example.com/path/apphtml
* web03.example.com/path/apphtml

nginx正在聆听虚拟URL ererp.example.com,并将其代理到群集。

这是我的配置:

upstream myCluster {
    ip_hash;
    server web01.example.com:80;
    server web02.example.com:80;
    server web03.example.com:80;
}
server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  ourerp.example.com;
    location / {
        rewrite ^(.*)$  /path/apphtml break;
        proxy_pass       http://myCluster;
    }
}

当我仅使用Proxy_pass时,然后将请求转发到Web01.example.com而不是Web01.example.com/path/apphtml

当我尝试添加URL重写时,它只需重写虚拟URL即可,我最终会使用ererp.example.com/path/apphtml。

是否可以在上游级别进行URL重写或在上游级别附加到应用程序的路径?

如果您想通过代理将/映射到/path/apphtml/,请使用:

proxy_pass http://myCluster/path/apphtml/;

请参阅此文档以获取更多信息。

您的rewrite语句的问题是替换字符串末尾缺少$1。请参阅此文档以获取更多信息,但是正如我上面指出的那样,您不需要rewrite语句,因为proxy_pass语句能够无论如何能够执行相同的工作。

最新更新