How to disable the x-forwarded-x headers on a single route so they do not get sent to the upstream.
How to disable the x-forwarded-x headers from a single route
How do I disable specific X-Forwarded-* headers on a single route?
Install the post-function plugin on the route and, in its access phase configuration, set the corresponding Nginx variable to nil (for example, ngx.var.upstream_x_forwarded_proto=nil to drop x-forwarded-proto, or ngx.var.upstream_x_forwarded_host=nil to drop x-forwarded-host) so the header isn’t sent to the upstream.
Steps
The easiest way to disable these headers is with a post-function plugin.
If you wanted to disable the x-forwarded-proto header for example:
-
Install the
post-functionplugin on the route you wish the header removed from. -
Add the following line to the access phase of the post function header field:
ngx.var.upstream_x_forwarded_proto=nilIf you wanted to disable the x-forwarded-host header for example:
-
Install the
post-functionplugin on the route you wish the header removed from. -
Add the following line to the access phase of the post function header field:
ngx.var.upstream_x_forwarded_host=nil