Claus-Theodor Riegg
8 years
Claus-Theodor Riegg
8 years
Claus-Theodor Riegg
7 years
Stefan Langenmaier
1 year
Andreas Vöst
6 months
Claus-Theodor Riegg
5 years
Andreas Vöst
7 months

nginx proxy_hide_header when used in multiple contextes

Updated . Posted . Visible to the public.

You can use proxy_hide_header in different contexts:

Syntax:  proxy_hide_header field;
Default: —
Context: http, server, location

Source Show archive.org snapshot

But if you use it in multiple contexts only the "lowest" occurrences are used.

So if you specify it in the server and location context (even if you hide different header) only the proxy_hide_header in the location block are used.

Example:

server {
[...]
  proxy_hide_header X-Example;
[...]
  location / {
    proxy_hide_header X-Foobar;
  [...]
  }
}

then if you access something:

curl -I https://example.com
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 09 Dec 2015 20:26:44 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
X-Example: foobar

You still get the X-Example because you used proxy_hide_header also in the location context. If you also want to hide X-Example you have to repeat it in the location:

server {
[...]
  proxy_hide_header X-Example;
[...]
  location / {
    proxy_hide_header X-Foobar;
    proxy_hide_header X-Example;
  [...]
  }
}
Last edit
Marc Dierig
License
Source code in this card is licensed under the MIT License.