scgi_store
The `scgi_store` directive determines where to store the response body of an SCGI request.
Description
The scgi_store directive is used to specify a file path where the body of a response from an SCGI server can be saved. This is particularly useful for caching purposes or for debugging, where response data is needed for analysis or later access. When this directive is set, NGINX will save the response body to the specified file before sending the response to the client. The filename can be defined dynamically using variables, which adds flexibility to the storage process.
The scgi_store directive accepts a single argument, which is the path to the output file where the response body will be stored. If the specified file already exists, it will be truncated before storing the new response body. It is supported in various contexts including http, server, and location, which provides versatility in its usage across different scopes of the NGINX configuration. Additionally, proper permissions must be set on the designated storage path, ensuring that the NGINX worker process has write access to the location.
When this directive is in use, consider using it alongside the scgi_pass directive to establish the connection to the SCGI backend. Since it can involve file system operations, performance implications should be considered especially if responses are large or frequent, as this could lead to file I/O becoming a bottleneck in high-traffic scenarios.
Config Example
location /scgi {
scgi_pass 127.0.0.1:4000;
scgi_store /var/www/html/scgi_response.txt;
}Ensure that the NGINX worker process has permission to write to the specified storage path.
Overwriting existing files may lead to data loss; ensure proper file management practices are in place.
Dynamic filename generation through variables should be carefully tested to avoid filesystem issues.