NGINX: Setting Different FastCGI Read Timeouts for Folders

Posted by Hart Jones on Server Fault See other posts from Server Fault or by Hart Jones
Published on 2012-04-10T01:52:56Z Indexed on 2012/04/10 5:33 UTC
Read the original article Hit count: 525

Filed under:

I have a PHP file in my /batch/ folder I run with an hourly CRON job. Unfortunately this process can often take a few minutes to complete so I have had to increase my fastcgi_read_timeout to 300 seconds for the entire server.

I was wondering if it would be possible to change the fastcgi_read_timeout directive for only files in my /batch/ folder and not the entire server. For example something like this...

location ~ \.php$ {
    fastcgi_pass   localhost:9000;  
    fastcgi_read_timeout 5;

    location /batch/ {
                fastcgi_read_timeout 300;
        }

    include /usr/local/nginx/conf/fastcgi_params;
}

So basically all PHP files on the server would have a 5 second timeout except PHP files in my /batch/ folder. Is this possible?

© Server Fault or respective owner

Related posts about nginx