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 ~ "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?

Related questions 1138 Node.js + Nginx - What now? 644 Nginx -- static file serving confusion with root & alias 0 Is it real to stop( exit from location ) execute location with good return code in nginx? Related questions 1138 Node.js + Nginx - What now? 644 Nginx -- static file serving confusion with root & alias 0 Is it real to stop( exit from location ) execute location with good return code in nginx? 3 Nginx setting expires header with proxy 579 Nginx no-www to www and www to no-www 0 setting nginx proxy_pass on ubuntu server 14 Edit a header value in nginx 0 Is it possible to specify an uri in Nginx proxy_pass? 396 NGinx Default public www location? Load 6 more related questions Show fewer related questions

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like