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;
}
I think there are two possibilities, of which the second would be the most flexible.
1
You could try:
File
snippets/location.fcgi.conf
(no need for location block there):2
Or I guess you could go like this.
NOTE: All include paths are always relative to the Nginx main config folder.
And yes, you can put them wherever you want provided that you have a symlink in place.
You can't inherit between location blocks but what you can do is use the include directive to place all your common configuration directives in one file and then include that in each location.