I am trying to add behavior for certain file types, but because my content isn't in the same folder, I hit a problem where the location match causes Nginx to look for content in the wrong folder.
With the following, a request for /wp-content/themes/ryu/fonts/ClearSans-Regular.woff
makes nginx look for the file at /opt/wordpress/wp-content/themes/ryu/fonts/ClearSans-Regular.woff
whereas if I comment the location ~* \.(ogg|ogv|svg|svgz|eot
... part, Nginx looks for content in the right place.
Any clue how I can achieve this?
server {
listen *:80;
root /opt/wordpress;
location ~* \.(eot|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
}
location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location /wp-content/ {
alias /opt/wp-content/;
try_files $uri =404;
}
location / {
alias /opt/public/;
expires 1d;
index index.html;
try_files $uri @wpsupercache;
}
}
Doesn't adding
within the
ogg...
location
stanza do what you want? That's assuming that the filesystem path for your example is/opt/wp-content/themes/ryu/fonts/ClearSans-Regular.woff