fastcgi_pass_header

The 'fastcgi_pass_header' directive specifies which headers should be passed from the FastCGI server to the client response.

Syntaxfastcgi_pass_header header_name;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The 'fastcgi_pass_header' directive allows you to define which HTTP headers received from a FastCGI server should be included in the response sent to the client. This directive can be specified multiple times within the same context, thereby allowing you to pass multiple headers. When a request is processed and the FastCGI server responds with headers, NGINX filters those headers based on the configuration provided with 'fastcgi_pass_header'. Only the headers that match those specified in this directive will be included in the final output to the client, while all other headers will be ignored. This is particularly useful for controlling which metadata or directives are communicated back to the client, improving security or focusing only on relevant data.

The 'fastcgi_pass_header' directive can be defined in 'http', 'server', and 'location' contexts, making it flexible for various configurations. By using this directive, administrators can ensure that sensitive headers are not exposed or that irrelevant headers are not cluttering responses. It's important to note that this directive is used in conjunction with the FastCGI configuration and requires the 'fastcgi_pass' directive to direct traffic to the FastCGI server.

An important aspect of its configuration is understanding that header names are case-insensitive, but the value may be case-sensitive depending on the application. Therefore, when defining headers to pass, ensure the exact spelling and case for values remain consistent for proper operational integrity.

Config Example

location /some_location {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_pass_header X-My-Custom-Header;
}

Make sure that the headers you want to pass actually exist in the FastCGI response; otherwise, nothing will be sent.

This directive is not effective if the FastCGI server is not properly configured to send the expected headers.

Headers specified in this directive must be correctly spelled and should match the case as sent by the FastCGI server.

← Back to all directives