Score:0

NGINX proxy_pass without changing URL

ua flag

My Goal

My goal is to redirect to a different web page without changing the URL in the address bar. So for example I want to redirect from https://my.site.com/path to https://external.com/other, but only the content of the page should change, not the URL.

Current configuration

This is what I have tried. I thought, that proxy_redirect might be a good idea, so I based the configuration on the NGINX docs. But while this does load the content of https://external.com/other, the URL in the address bar changes to https://my.site.com/other. The domain name stays the same, but the path changes.

location = /path {
    proxy_pass https://external.com/other;
    proxy_redirect default;
}
in flag
Does this answer your question? [How can I forward requests from my web server?](https://serverfault.com/questions/1035016/how-can-i-forward-requests-from-my-web-server)
Andy Sukowski-Bang avatar
ua flag
@GeraldSchneider No, that doesn't answer my question. I'm basically doing what the answer suggests, but I don't want the path in the URL to change, when making a request. I want it to stay the same, while only the content of the site changes.
in flag
No, you are not doing it. What you want is not a redirect, it's a plain reverse proxy.
in flag
Chances are that the redirect you are still getting from the backend server, which needs to be configured properly.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.