如何解决nGinx 没有将请求的 URI 传递给 proxy_pass 服务器
server {
listen 80;
root /app;
location / {
index index.html;
}
location /api/users {
proxy_pass http://server1-srv:3000/;
proxy_set_header X-Forwarded-For $remote_addr;
}
location /api/chats {
proxy_pass http://server1-srv:4000/;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
请求在 localhost/api/users 工作正常,它正在访问 proxy_pass 服务器 http://server1-srv/3000/ 在 /路线
- 但是像 localhost/api/users/clearcookie 这样的请求没有在 /clearcookieproxy_pass 服务器 http://server1-srv:3000/ /strong> 路线
我想要的是:-
- 对于所有请求,如 localhost/api/users、locahost/api/users/clearcookie、localhost/api/users/someotherroute 等
- 所有结果都应分别为 http://server1-srv:3000、http://server1-srv:3000/clearcookie、http://server1-srv:3000/someotherroute
- 不像 http://server1-srv:3000/api/users 或 http://server1-srv:3000/api/users/clearcookie
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。