scgi_max_temp_file_size

The `scgi_max_temp_file_size` directive limits the maximum size of temporary files created for SCGI requests.

Syntaxscgi_max_temp_file_size size;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The scgi_max_temp_file_size directive is used in NGINX to control the storage of temporary files when handling SCGI requests. Specifically, this directive dictates the maximum allowable size for these temporary files, which are created when the request body exceeds a certain limit. If the size of the temporary file exceeds the value set by this directive, NGINX will return an error instead of processing the request further, which helps prevent excessive disk usage and potential performance issues.

This directive can be configured in the http, server, or location context, allowing for flexibility based on application requirements. When set, it must be assigned a valid size unit such as bytes, kilobytes (k), megabytes (m), etc. If the directive is not specified, the default value will apply, which effectively means there is no upper limit unless configured otherwise.

Using this directive appropriately can be crucial for maintaining control over resource consumption in an NGINX server. For environments with stringent storage limits, such as shared hosting or resource-constrained scenarios, it can prevent unauthorized excessive use of temporary file storage, thereby improving overall reliability.

Config Example

http {
    server {
        location /scgi {
            scgi_pass 127.0.0.1:4000;
            scgi_max_temp_file_size 10m;
        }
    }
}

Setting this value too low may lead to frequent errors if your application generates larger request bodies than allowed.

Not configuring this directive may result in uncontrolled growth of temporary files, impacting disk space.

Make sure the size is appropriate for the expected load; review request body sizes from your application.

← Back to all directives