more_set_input_headers

The `more_set_input_headers` directive allows you to add, modify, or clear input headers in NGINX configurations.

Syntaxmore_set_input_headers header1; [header2...];
Defaultnone
Contexthttp, server, location, if in location
Arguments1+

Description

The more_set_input_headers directive is part of the ngx_headers_more module, which is used for managing HTTP headers in NGINX. This directive specifically targets input headers and can be employed in various contexts such as http, server, location, and inside an 'if' block within a location. The directive can take one or more header specifications as arguments, allowing for flexible modifications. Each input header can be set, replaced, or removed based on predefined conditions.

When using more_set_input_headers, it's possible to employ different options. For instance, by using the -r flag, existing headers can be replaced only if they already exist. This adds a layer of control over header manipulation, ensuring that you don't unintentionally overwrite headers that are not present. Additionally, you can specify content-type filtering, where the directive will only apply to certain headers based on the content type of the request. The usage of multiple MIME types in one call is also supported, providing further granularity in header management.

Config Example

location /example {
    more_set_input_headers 'X-Example-Header: value';
    more_set_input_headers -r 'X-Existing-Header: new-value';
}

Ensure the headers you are trying to set exist in the request; otherwise, replacement will have no effect when using the -r flag.

Using unfunded variables in headers may lead to unexpected behaviors if they are not properly defined before usage.

← Back to all directives