scgi_param

The `scgi_param` directive sets SCGI parameters for requests to SCGI servers.

Syntaxscgi_param name value [empty];
Defaultnone
Contexthttp, server, location
Arguments2-3

Description

The scgi_param directive is utilized in NGINX to define parameters that will be passed to SCGI (Simple Common Gateway Interface) applications when making proxy requests. It allows for the passing of variables and values that the SCGI server can utilize during the request handling process. This directive can take two to three arguments: the parameter name, the parameter value, and optionally a flag indicating whether the parameter is to be removed from the request header if it has an empty value.

When using scgi_param, you can set custom parameters that align with the requirements of the SCGI applications you are proxying. The parameters are sent as part of the SCGI request, allowing the backend application to dynamically respond based on these values. Therefore, it is essential to ensure that the parameters names correspond to those expected by the SCGI application to avoid any issues in request handling.

One often overlooked aspect is that when the parameter value is an empty string, it will not be sent unless the optional third argument is provided with a value of 'on', which instructs NGINX to include empty parameters in the request. This feature can be critical for debugging or ensuring that the receiving SCGI app functions as expected even when certain parameters are not provided or are empty.

Config Example

location /example {
    scgi_pass 127.0.0.1:9000;
    scgi_param SCRIPT_NAME /example;
    scgi_param QUERY_STRING $query_string;
    scgi_param REQUEST_METHOD $request_method;
}

Ensure that the parameter names match what the SCGI application expects.

Empty parameters will not be sent unless explicitly instructed with the 'empty' option.

Parameter values should be URL-encoded if they include characters that need encoding.

← Back to all directives