Ensuring Redirects on a Proxied Server work correctly

So I am currently trying to understand what configuration is a good idea for an nginx proxy. I am a bit stuck on the following two options:

  • proxy_set_header Host $host;
  • proxy_redirect default; (which is the default anyway and thus superflous)

If I understand it correctly then they both seem to target the same goal: ensuring that redirect work correctly. Setting the header variable Host to $host (which is the name of the nginx server, while the default ($proxy_host) is the name of the proxy server), ensures that the proxy server "views itself as $host" and thus links paths of type /some/sub/path to resources at $host/some/sub/path instead of $proxy_host/some/sub/path.

But this seems to be the purpose proxy_redirect is for as well. So I am not sure what to make of this. Maybe I am not really understanding those parameters quite right.


The role for Host header is for the upstream server to select the correct virtual host for serving the site. Also, the application uses it to determine that visitor connects to correct domain.

The proxy_redirect is used to modify Location / Refresh fields in the responses the upstream server sends back to visitors.

So, these two features complement each other. The Host header is used to route request, while proxy_redirect is used to modify response.