fastcgi_max_temp_file_size

The 'fastcgi_max_temp_file_size' directive sets the maximum allowed size of temporary files for FastCGI responses.

Syntaxfastcgi_max_temp_file_size size;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The 'fastcgi_max_temp_file_size' directive specifies the maximum size that temporary files, created by NGINX for buffering FastCGI response data, may reach. If the size of the response exceeds this limit, NGINX will return a 502 Bad Gateway error and reject the request. This is particularly useful for managing server resources and ensuring that excessively large FastCGI responses do not consume all available disk space.

This directive can be applied in several contexts including 'http', 'server', and 'location', allowing flexibility in configuration depending on the use case. The value is defined in bytes, and care should be taken to set an appropriate size based on the expected volume of FastCGI responses. Too small a size may lead to increased error rates, whereas too large a value may lead to excessive disk usage, especially under high load.

To apply the directive, it is necessary to consider the workload characteristics of your application and the disk space available. Monitoring and adjusting this configuration may be required as response sizes vary over time or based on user load patterns, ensuring that your application remains performant and resilient against unexpected traffic spikes.

Config Example

location /cgi-bin {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_max_temp_file_size 16m;
}

Setting the value too low can lead to frequent 502 errors if FastCGI responses exceed the limit.

Not all FastCGI applications respect the temporary file limits, which may lead to unexpected behavior.

Ensure that the server has sufficient disk space available for temporary files when using large limits.

← Back to all directives