fipa
July 7, 2010, 2:32pm
1
I don’t understand the following error:
the “alias” directive may not be used inside location given by regular
expression
From the docs it seems possible:
http://wiki.nginx.org/NginxHttpCoreModule#alias
I’m running 0.7.38
Here is my conflictual declaration:
location ~* ^/uploads/([\w-/]+.(jpg|m4v|mp4|ogv|png)) {
alias $rails_path/uploads/production/$1;
}
I want to map the request /uploads/assets/myfile.png to
/uploads/production/assets/myfile.png on disk
Thanks
fipa
July 7, 2010, 2:40pm
2
On Wed, Jul 07, 2010 at 02:32:57PM +0200, Fernando P. wrote:
I don’t understand the following error:
the “alias” directive may not be used inside location given by regular
expression
From the docs it seems possible:
Module ngx_http_core_module
I’m running 0.7.38
This is possible since 0.7.40.
Here is my conflictual declaration:
location ~* ^/uploads/([\w-/]+.(jpg|m4v|mp4|ogv|png)) {
alias $rails_path/uploads/production/$1;
}
I want to map the request /uploads/assets/myfile.png to
/uploads/production/assets/myfile.png on disk
In this case you do not need regex:
location /uploads/ {
alias $rails_path/uploads/production/;
}
BTW, it’s better to not use “set $rails_path /rails;”,
but set it in alias:
location /uploads/ {
alias /rails/uploads/production/;
}
–
Igor S.
http://sysoev.ru/en/
fipa
July 7, 2010, 2:41pm
3
07.07.10, 16:32, “Fernando P.” [email protected] :
Here is my conflictual declaration:
location ~* ^/uploads/([\w-/]+.(jpg|m4v|mp4|ogv|png)) {
alias $rails_path/uploads/production/$1;
root $rails_path/uploads/production;
try_files /$1 =404;
}
I want to map the request /uploads/assets/myfile.png to
/uploads/production/assets/myfile.png on disk
Thanks
–
br, Denis F. Latypoff.
fipa
July 7, 2010, 3:51pm
4
location /uploads/ {
alias /rails/uploads/production/;
}
It doesn’t catch the following request:
/uploads/assets/4/original/paypal_logo.png
Is there something I didn’t understand?
fipa
July 7, 2010, 4:30pm
5
location ^~ /uploads/ {
alias /rails/uploads/production/;
}
Ok I fixed it by adding ^~ , it was a bit further down in the docs. It’s
much cleaner than using regexps.
fipa
July 7, 2010, 2:59pm
6
Thanks Igor,
Indeed updating Nginx to its latest version solved the problem.
I’ll also edit my conf files according to your recommendations.
Thanks Denis for making me discover about the try_files declaration,
it’s interesting to know about it.
fipa
July 7, 2010, 5:41pm
7
Hello!
On Wed, Jul 07, 2010 at 02:32:57PM +0200, Fernando P. wrote:
I don’t understand the following error:
the “alias” directive may not be used inside location given by regular
expression
From the docs it seems possible:
Module ngx_http_core_module
I’m running 0.7.38
Changes with nginx 0.7.40
09 Mar 2009
*) Feature: the "location" directive supports captures in regular
expressions.
*) Feature: an "alias" directive with capture references may be used
inside a location given by a regular expression with captures.
…
It’s just not in 0.7.38 (which is rather old, and from 0.7.*
branch when it wasn’t yet marked stable).
It’s time to upgrade.
Maxim D.