proxy_pass_trailers

The `proxy_pass_trailers` directive controls the handling of HTTP trailers in upstream responses. — NGINX HTTP Core

proxy_pass_trailers
httpserverlocation
Синтаксисproxy_pass_trailers on | off;
По умолчаниюoff
Контекстhttp, server, location
МодульNGINX HTTP Core
Аргументыflag

Описание

The `proxy_pass_trailers` directive is used in NGINX configurations to dictate whether or not HTTP trailers (i.e., additional headers sent after the body of the HTTP response) should be passed along from an upstream server to the client. By default, trailers may not be enabled, meaning that they would not be forwarded in the response, impacting scenarios where trailers are necessary for proper client processing. When this directive is set to `on`, it indicates that the NGINX server should allow trailers to be collected from the upstream response and sent back to the client. This is especially relevant in applications where trailer information contains important metadata or response details that need to be processed after the response body has been received. The directive operates within the `http`, `server`, and `location` contexts, providing flexibility in its application across different configuration scopes. In terms of performance, enabling trailer processing may incur slight overhead, hence it's typically recommended only when absolutely necessary. Each trailer is added to the response after the body content and must conform to HTTP standards to ensure compatibility with clients that expect this kind of response structure.

Пример конфига

http {
    server {
        location /api {
            proxy_pass http://backend;
            proxy_pass_trailers on;
        }
    }
}

Ensure that the backend server actually sends trailers; otherwise, enabling this directive has no effect.

Be mindful of clients that do not support trailers, as it may lead to compatibility issues.