Nginx Proxy_Hide_Header and Variable
I Need to Hide Some Headers for a Specific Path. I Have the Following Nginx Config: Server { Listen 80; Location / { Set $X_Hide_Header "X-Foo-Bar"; If ($Uri ~...
I need to hide some headers for a specific path. I have the following nginx config:
server {
listen 80;
location / {
set $x_hide_header "X-Foo-Bar";
if ($uri ~ "some-path$") {
set $x_hide_header "Header-I-Need-To-Hide";
}
proxy_hide_header $x_hide_header;
proxy_pass
}
}
But the header still exists. If I add proxy_hide_header "Header-I-Need-To-Hide" it disappears, but I need to hide it only for a specific path, as was said above. Looks like nginx interprets the variable in proxy_hide_header as string literal. Is there any workaround?
I can do this by defining another location and copying all from the current one + proxy_hide_header, but I won't do this. Maybe there is another solution?