add_trailer_inherit

The `add_trailer_inherit` directive configures whether trailer headers from proxied responses are inherited in the NGINX HTTP server context.

Syntaxadd_trailer_inherit on | off;
Defaultoff
Contexthttp, server, location, if in location
Arguments1

Description

The add_trailer_inherit directive provides a mechanism for configuring how trailer headers (that are headers sent after the main response body) are handled in the context of a proxied server. When set, it allows these trailer headers to be inherited from the proxied upstream server response to the client response. This can be particularly useful when dealing with transfer encodings like chunked, where additional headers need to be sent at the end of the response to provide the client with necessary metadata.

This directive accepts a single argument which is a boolean value: either 'on' or 'off'. If set to 'on', NGINX will include any trailer headers received from the upstream server in the response sent to the client. If set to 'off', these headers will not be included. It is essential to realize that the inheritance of trailer headers can have implications for client behavior, especially in scenarios involving HTTP/1.1 chunked transfers. Consequently, careful consideration should be given to both the upstream server configuration and client expectations when using this directive.

Config Example

http {
    server {
        location /example {
            proxy_pass http://upstream_server;
            add_trailer_inherit on;
        }
    }
}

Ensure that the upstream server actually sends trailer headers; otherwise, enabling this directive has no effect.

Overusing trailer headers can lead to unexpected client-side behavior if clients do not handle them appropriately.

← Back to all directives