ajp_pass_request_headers

The `ajp_pass_request_headers` directive controls whether NGINX passes request headers to the AJP backend server.

Syntaxajp_pass_request_headers on | off;
Defaultoff
Contexthttp, server, location
Argumentsflag

Description

The ajp_pass_request_headers directive allows users to specify whether NGINX should forward the client's request headers to an AJP backend server when processing requests. By setting this flag to 'on', NGINX will include the specified request headers such as 'User-Agent', 'Accept', 'Host', etc., in its AJP requests. This is particularly useful for applications that rely on these headers for processing client requests correctly.

The directive works within the context of http, server, or location blocks in the NGINX configuration. If enabled, it ensures that your backend application has access to the necessary client information, which can influence how it generates responses (for example, customizing responses based on the User-Agent header). If set to 'off', the application may not receive important metadata that could ensure proper handling of requests.

It is important to note that the performance may vary depending on the number of headers being passed and the backend application’s capabilities to handle them effectively. Therefore, administrators should be cautious in using this directive based on their application requirements and performance expectations.

Config Example

http {
    upstream tomcats {
        server 127.0.0.1:8009;
    }

    server {
        listen 80;

        location / {
            ajp_pass tomcats;
            ajp_pass_request_headers on;
        }
    }
}

Not passing headers can lead to unexpected application behavior due to missing metadata.

If enabled, performance may decrease due to the increased size of AJP requests.

Ensure the backend can handle all forwarded headers appropriately to avoid issues.

← Back to all directives