fastcgi_pass_request_headers

The 'fastcgi_pass_request_headers' directive controls the passing of request headers to FastCGI servers.

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

Description

The 'fastcgi_pass_request_headers' directive is used in NGINX configurations to determine whether the headers from the client request should be forwarded to the FastCGI server. This directive accepts a boolean flag as its argument, which allows you to enable or disable the passing of these headers. When set to 'on', NGINX passes all headers from the client request, including those that may be modified or added by intermediate proxies or other services. Conversely, setting it to 'off' means that no request headers will be sent to the FastCGI server at all.

Using this directive effectively is essential for applications that rely on certain headers to function correctly, such as HTTP_REFERER or USER_AGENT. Not passing these headers could potentially lead to issues in web applications or content management systems that expect specific request headers. It is also important to take into account the security implications of forwarding certain headers, as it may expose sensitive information from client requests that could be misused.

This directive can be set in the http, server, or location contexts, making it flexible according to your configuration requirements. Proper use and understanding of this directive, particularly in terms of performance and security, is key when integrating NGINX with FastCGI applications.

Config Example

location ~ \.php$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_pass_request_headers on;
    include fastcgi_params;
}

Be cautious when enabling headers, as they may contain sensitive information.

Ensure that your FastCGI application can handle the headers being passed properly.

← Back to all directives