nginx-位置块与路径不匹配

时间:2020-04-30 00:51:21

标签: nginx server

我正在使用Nginx服务Web应用程序,并且我希望发出包含 / apacheserver / 到Apache的反向代理(监听8090)和 / 的请求。到节点服务器(侦听8000)。

我的位置信息块运行正常,但是例如当我尝试访问 / apacheserver / subdirectory 时出现错误,它将我重定向到 / subdirectory ,并且节点满足该请求这不是我想要的。我该如何解决?谢谢!

server {
        root /var/www/html;
        index index.php index.html;

        server_name example.com;

        location ^~ /apacheserver/ {
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:8090;
                break;
        }

        location / {
                proxy_redirect off;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $host;
                proxy_pass http://127.0.0.1:8000;
                break;
        }
}

0 个答案:

没有答案