scgi_pass_header
The `scgi_pass_header` directive allows you to specify headers that should be passed from the SCGI server in the response to the client.
Description
The scgi_pass_header directive is utilized in NGINX configurations to control the forwarding of specific headers from a SCGI server to the client. When configured, NGINX will ensure that the specified headers included in the SCGI response are sent along with the HTTP response. This is particularly useful for preserving important metadata provided by the SCGI application, such as content type or any custom application headers that the client might require.
The directive is designed to accept a single argument, which represents the name of the header to be passed. The directive can be used in the http, server, or location contexts, allowing for flexible application depending on the scope of the configuration. If multiple headers are required, the directive can be specified multiple times, once for each header to include. Additionally, it is essential to ensure that the specified headers do exist in the SCGI response; otherwise, they will not be sent to the client, leading to incomplete data being provided.
In practice, this directive operates by intercepting headers that are part of the response from the SCGI server. By specifying which headers to pass, administrators can finely control client-side behavior and data management, ensuring that clients are aware of all necessary information while adapting to the specific needs of the application being served.
Config Example
server {
listen 80;
location /myapp {
scgi_pass 127.0.0.1:9000;
scgi_pass_header X-My-Custom-Header;
scgi_pass_header Content-Type;
}
}Remember to use the exact case of the header name as HTTP headers can be case-sensitive in some contexts.
If the header does not exist in the SCGI response, it will not appear in the client response, which can lead to confusion.
Using too many scgi_pass_header directives without need can lead to performance overhead as headers are processed and passed individually.