Welcome! Log In Create A New Profile

Advanced

Re: nginx proxy pass only works for root location

Maxim Dounin
November 18, 2021 08:40PM
Hello!

On Thu, Nov 18, 2021 at 05:31:27PM -0500, gunitinug wrote:

> Maxim Dounin Wrote:
> -------------------------------------------------------
> > Hello!
> >
> > On Thu, Nov 18, 2021 at 05:51:08AM -0500, gunitinug wrote:
> >
> > > Hello. I posted a question:
> > >
> > >
> > https://unix.stackexchange.com/questions/678060/nginx-proxy-pass-only-
> > works-for-root-location
> >
> > 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
> > details).
> >
> > 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.
>
> Loading of the app in browser fails.
>
> I checked the console and it says:
>
> Loading failed for the <script> with source
> “http://my_vps_public_ip/static/js/bundle.js”.
> Loading failed for the <script> with source
> “http://my_vps_ip_public_ip/static/js/0.chunk.js”. ecapp:30:1
> Loading failed for the <script> with source
> “http://my_vps_ip_public_ip/static/js/main.chunk.js”. ecapp:30:1

So it looks like a problem with links in the response.

As previously suggested, recommended approach would be to configure
your backend to return links with correct prefix. Refer to your
app documentation on how to do it.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

nginx proxy pass only works for root location

gunitinug November 18, 2021 05:51AM

Re: nginx proxy pass only works for root location

Maxim Dounin November 18, 2021 08:38AM

Re: nginx proxy pass only works for root location

gunitinug November 18, 2021 05:31PM

Re: nginx proxy pass only works for root location

Maxim Dounin November 18, 2021 08:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 51
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready