proxy_ignore_headers

The `proxy_ignore_headers` directive configures NGINX to ignore specific headers from proxied responses.

Syntaxproxy_ignore_headers header_name ...;
Defaultnone
Contexthttp, server, location
Arguments1+

Description

The proxy_ignore_headers directive instructs NGINX to omit specified headers from the responses that are proxied to clients. This can be useful for controlling the information that is passed back to users, particularly when dealing with sensitive headers or when you want to enforce specific cache behaviors. You can provide one or more headers as arguments, and NGINX will disregard these headers in responses that it passes through the proxy.

This directive can be set in various contexts including http, server, and location, allowing for flexible configurations based on the specific needs of your server setup. When specifying the headers to ignore, you can use the names of headers such as "Cache-Control", "Expires", etc. If multiple headers are specified, they should be separated by spaces. The directive does not manipulate the proxied server's configurations, and it only alters what is sent back to the requester from NGINX itself, ensuring that potentially unwanted information is filtered out before reaching the client.

Config Example

location /example {
    proxy_pass http://backend;
    proxy_ignore_headers Cache-Control Expires;
}

Ignoring headers can lead to unexpected behavior, especially for caching; ensure the ignored headers are not critical for desired client behavior.

Be cautious about ignoring security-related headers that may protect users from attacks.

← Back to all directives