cgi_timeout
Sets the timeouts for CGI processing requests in NGINX.
Description
The cgi_timeout directive in NGINX is used to define time limits for processing CGI requests. It helps manage how long NGINX waits for a CGI script to produce output, thus preventing resource hogging and ensuring faster response times for users. When the timeout period is reached and no output has been produced, NGINX will terminate the request, returning an error to the client.
This directive can accept one or two arguments, allowing you to specify different timeouts for the connection and the response. The first argument sets the timeout for processing the connection to the CGI script, while the second, optional argument can be used to specify the timeout for output generation. Both timeouts are specified in milliseconds, providing flexibility in managing different conditions that may affect the execution of CGI scripts.
It's important to note that setting this directive appropriately is crucial for maintaining server performance, especially under conditions of high traffic or when using scripts that may execute long-running tasks. Misconfiguration can lead to clients experiencing delays or aborted responses if the script execution exceeds the defined timeout limits.
Config Example
location /cgi-bin/ {
cgi_timeout 5000; # Sets a 5-second timeout for CGI script execution
}Setting timeouts too low may result in legitimate requests being dropped before completion.
Ensure that the specified timeout values are in milliseconds to avoid unexpected behavior.