Make relative paths in proxy go to the right server

AussieSusan nginx-forum at forum.nginx.org
Tue May 24 05:25:05 UTC 2022


I am a total newbie to this and I don't even know if what I want to do is
possible.

I have a web server that locally serves some of the files but in one case
needs to  pass the web requests on to another server.

For example: "https://myserver.com/weather" needs to be handled locally, but
"https://myserver.com/whatever" needs to go to a different server on the
network. To do this I have:

       location /whatever {
                proxy_pass http://10.12.45.12:1234/;
        }

This works OK but the pages served by the other server have relative paths
to files that are relative to THAT server. The user's browser converts the
relative paths from "other_base/file_path.css" to
"https://myserver.com/other_base/file_path.css".

I could add another 'location' entry to my configuration for "/other_base"
but there is no guarantee that the 'other_base" name will always be the
same.

What do I need to put in the Nginx configuration so that the files relative
to the other server are correctly redirected (e.g.
https://myserve.com/whatever/other_base/file_path.css")

Susan

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,294234,294234#msg-294234



More information about the nginx mailing list