Location merging
September 26, 2012 03:28PM
This location

location = /favicon.ico {
include caching.conf;
}


With this in caching.conf

location ~ \.(jpg|png|jar|js|xml|css|sha1|md5|txt|pom|ogg|gif|mp3|base64|ico|zip|gz|kmz|bz2|sdf|JPG|pdf|ods|mm|hta|flv|dsk)$ {
expires max;
}

Fails with

Testing nginx configuration: nginx: [emerg] location "\.(jpg|png|jar|js|xml|css|sha1|md5|txt|pom|ogg|gif|mp3|base64|ico|zip|gz|kmz|bz2|sdf|JPG|pdf|ods|mm|hta|flv|dsk)$" cannot be inside the exact location "/favicon.ico" in /etc/nginx/caching.conf:5

To enable this, you could merge location hierarchies. In this case, the regular expression in the second location matches on the first one so the entire rule

location = /favicon.ico {
location ~ \.(jpg|png|jar|js|xml|css|sha1|md5|txt|pom|ogg|gif|mp3|base64|ico|zip|gz|kmz|bz2|sdf|JPG|pdf|ods|mm|hta|flv|dsk)$ {
expires max;
}
}

essentially becomes

location = /favicon.ico {
expires max;
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 127
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready