我有NGINX代理请求到机器上运行的几个服务,位置指令如下 –
location = / { proxy_pass http://localhost:5000; } location / { proxy_pass http://localhost:8080; } location ^~ /index.html { proxy_pass http://localhost:5000; } location ^~ /static/ { proxy_pass http://localhost:5000; } location ~* .(config.json|service-worker.js)$ { proxy_pass http://localhost:5000; }
所有这一切工作正常,但我有另一个服务,我想通过删除前缀重写的请求path。 也就是要求
https://myserver.com/service和https://myserver.com/service/some/path
应该作为传递给服务
http://localhost:8761和http://localhost:8761/some/path
请注意,对于其他服务,需要传递完整path。 我试过下面的configuration –
location /service/ { proxy_pass http://localhost:8761/; }
但这只适用于https://myserver.com/service而不是当有尾随path。
如果有人能帮我弄明白这一点,我将不胜感激。 谢谢!