nGinx 没有将请求的 URI 传递给 proxy_pass 服务器

时间:2021-04-18 05:58:32

标签: nginx docker-compose nginx-reverse-proxy nginx-config nginx-location

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 这样的请求没有在 /clearcookie< 处访问 proxy_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

0 个答案:

没有答案