首页 > 解决方案 > Url 参数在 NGINX 子文件夹重定向中不起作用

问题描述

当我在本地(127.0.0.1)使用网络服务时,带参数的端点正常工作,网络服务返回正常内容。

localmachine 中的 URL 为:http://localhost:8888/servico/search/findByEmpresaId?empresaId=1

此查询由 Web 服务返回正确。

要将 https 添加到 webervice,我使用 NGINX 并重定向到子文件夹。新网址是:

https://systemapp/servico/search/findByEmpresaId?empresaId=1

但是在 NGIX 服务器上,将不带参数的 url 发送到 webservice

http://localhost:8888/search/findByEmpresaId

我使用的 .conf 是:

location ~/webservice(.*)$ {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    proxy_pass http://localhost:8888$1;
}

使用此重定向,端点 https://systemapp/webservice/empresa?test=1;teste2=2 仅在使用 https://systemapp/webservice/empresa/1/2 时有效

标签: nginxhttps

解决方案


感谢@RichardSmith

location ~/webservice(.*)$ {
    include /config/nginx/proxy.conf;
    resolver 127.0.0.11 valid=30s;
    proxy_pass http://localhost:8888$1$is_args$args;
}

推荐阅读