nginx proxy_pass 404 error, don't understand why

前端 未结 4 2166
梦毁少年i
梦毁少年i 2020-12-08 06:26

I am trying to pass off all calls to /api to my webservice but I keep getting 404s with the following config. Calls to / return index.html as expected. Does anyone know why?

4条回答
  •  悲哀的现实
    2020-12-08 07:12

    By some reason proxy_pass in Nginx cuts header "Host" before passing to upstream, and request catches by default server, and even proxy_header_pass doesn't helps, so I've to explicitly set it:

    location / {
        proxy_set_header Host $host;
        proxy_pass  http://backend;
    }
    

提交回复
热议问题