fastcgi_temp_path

The `fastcgi_temp_path` directive sets the path for temporary files used by the FastCGI handler in NGINX.

Syntaxfastcgi_temp_path path1 [path2 [path3 [path4]]];
Defaultnone
Contexthttp, server, location
Arguments1-4

Description

The fastcgi_temp_path directive defines the file path where NGINX stores temporary files created during FastCGI processing. This is particularly useful for handling large responses or when the output from FastCGI is buffered. The specified path must be writable by the NGINX worker processes. You can specify up to four directory paths separated by whitespace; NGINX will use the first available directory for temporary file storage, which allows for spreading load across multiple disks if needed.

When a FastCGI request is processed and the response exceeds certain buffer limits, NGINX writes the data into the specified temporary files until the entire response is handled before sending it to the client. This improves overall performance by allowing NGINX to manage memory usage efficiently and prevents failures due to excessive memory consumption. The directory structure may need to be created in advance, and it is essential to set appropriate permissions to avoid access issues.

Config Example

fastcgi_temp_path /var/tmp/nginx/fastcgi_temp;

Ensure that the specified path exists and is writable by the NGINX worker processes to avoid errors.

If using multiple paths, be aware that the order matters; NGINX will check the paths sequentially until it finds a writable location.

Monitor the storage capacity of the temporary directory to prevent running out of space, which can lead to request failures.

← Back to all directives