Answer the question
In order to leave comments, you need to log in
Nginx, try_files - why doesn't it work?
We have this config -
set $static_root /home/....
set $folder ...
location @vincent {
proxy_pass http://vincent;
}
location ~* "/img/([a-z0-9\-]{2,5})/([a-z]{1,3})/([0-9]{1,2}\.jpg)" {
set $cache $static_root/cached/$folder/$1/$2/$3;
set $cache_common $static_root/cached/common/$1/$2/$3;
try_files $cache $cache_common @vincent;
#if (-f $cache) {
# return 301; break;
#
}
Answer the question
In order to leave comments, you need to log in
try_files does not accept absolute paths, always appending the contents of $document_root before the string passed. So you need to set the normal value of the root.
You get something like:
location ~* "/img/([a-z0-9\-]{2,5})/([a-z]{1,3})/([0-9]{1,2}\.jpg)" {
root /;
set $cache $static_root/cached/$folder/$1/$2/$3;
set $cache_common $static_root/cached/common/$1/$2/$3;
try_files $cache $cache_common @vincent;
}
location ~* "/img/([a-z0-9\-]{2,5})/([a-z]{1,3})/([0-9]{1,2}\.jpg)" {
root $static_root;
set $cache /cached/$folder/$1/$2/$3;
set $cache_common /cached/common/$1/$2/$3;
try_files $cache $cache_common @vincent;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question