nginx proxy pass only works for root location
mdounin at mdounin.ru
Thu Nov 18 13:36:58 UTC 2021
On Thu, Nov 18, 2021 at 05:51:08AM -0500, gunitinug wrote:
> Hello. I posted a question:
First of all you may want to define "won't work". What exactly
happens, what goes wrong?
Note that in general there are no problems with proxying in nginx:
it will happily get a request from the client and pass it the
backend server, and will return the response from the backend
server to the client.
But proxying, especially if you are trying to proxy with changed
URI, might result in incorrect resulting page if your backend
server uses absolute links in responses. Or your backend server
might not like the request coming from nginx and will try to
redirect the client.
Most common issue which happens when proxying is wrong URLs in
redirections returned by the backend server. This is something
nginx is usually able to fix itself with the default settings of
the proxy_redirect directive. In complex cases some adjustment
might be needed though (see http://nginx.org/r/proxy_redirect for
Another common issue is wrong links in the HTML pages
returned. In some cases these can be fixed with sub_filter
(http://nginx.org/r/sub_filter), but usually a better idea is to
configure your backend server to return correct links instead.
More information about the nginx