Skip to main content What happens with proxy_redirect set to off in location with proxy_pass? : r/nginx
Go to nginx
•

What happens with proxy_redirect set to off in location with proxy_pass?

Hi!
I have kind of newbie question. I'm trying to understand proxy_redirect directive and can't find info about one thing - what happens when it is set to off. Now let's take a setup with docker for example - I would assume that setting proxy_redirect like in the example would give the same effect as setting it to off. Is that right?

location /container {
proxy_pass http://container;
proxy_redirect http://container/ $scheme://$http_host/;
}

Go all-in with one consistent WiFi price for 5 years.
Thumbnail image: Go all-in with one consistent WiFi price for 5 years.
Sort by:
Best
Open comment sort options

From Nginx proxy_redirect

The off parameter cancels the effect of the proxy_redirect directives inherited from the previous configuration level.

So:

Http{
  proxy_redirect example1;
  Server{
    proxy_redirect example2;
    Location{
      proxy_redirect off;
    }
  }
}

Stuff in the http block has example1 applied, stuff in the server block has example1 and example2 applied, and stuff in the location block only has proxy_redirect default; applied.

Alright, but since "proxy_redirect default" cannot be used with "proxy_pass" directive with variables, then what happens when we use variables in proxy pass and set "proxy_redirect off" (edit: when there is no proxy_redirect in parent block)?

More replies
More replies