How to create location blocks in nginx for a single file but have it follow the rules of another location block in addition to it's own?
Posted
by
Ryan Detzel
on Server Fault
See other posts from Server Fault
or by Ryan Detzel
Published on 2011-03-17T16:03:10Z
Indexed on
2011/03/17
16:11 UTC
Read the original article
Hit count: 210
nginx
I have a location block for / that does all of my fastcgi stuff and it has a normal timeout of 10s. I want to be able to have different timesouts for certain files(/admin, sitemap.xml). Is there an easy way to do this without copying the entire location block for each location?
location /admin{
fastcgi_read_timeout 5m;
#also use the location info below.
}
location /sitemap.xml{
fastcgi_read_timeout 5m;
#also use the location info below.
}
location / {
fastcgi_pass 127.0.0.1:8014;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for;
}
© Server Fault or respective owner