fipa
August 9, 2010, 11:16am
1
Hi,
I am trying to catch any request that has WORD in the url, eg:
catch: http://example.org/whatever/path/WORD/file.pdf
don’t catch: http://example.org/some/other/path/anotherfile.jpg
and if simple to do, don’t catch: http://example.org/folder/WORD.doc
I tried:
location ^~ /WORD/ {}
location WORD {}
location ~* WORD {}
But none seemed to do want I want*.
Thanks for your advice
*: unless I’m hitting again this stupid caching thing, but this time I
tried in safari and it didn’t work either, so it should be cleared.
fipa
August 9, 2010, 11:20am
2
On Mon, Aug 09, 2010 at 11:16:53AM +0200, Fernando P. wrote:
Thanks for your advice
Place
location ~ /WORD/ {
…
}
as the first location in a server.
–
Igor S.
http://sysoev.ru/en/
fipa
August 9, 2010, 11:53am
3
Place
location ~ /WORD/ {
…
}
as the first location in a server.
I have placed as the first location of my server:
location ~ /WORD/ {
internal;
root …
}
But it still gets served directly by nginx. I’d like to use it with
X-Accel-Redirect, but first I need to make sure that people can’t access
these files directly.
fipa
August 9, 2010, 11:59am
4
I’ll use actual values:
A public request looks like:
/uploads/2009/product.jpg
An a restricted request looks like:
/uploads/2009/restricted/product.mp4
So I have:
location ~ /restricted/ {
internal;
root …;
}
location ^~ /uploads/ {
root …;
}
Is it my /uploads/ location which fits maybe better the request and
confuses nginx?
fipa
August 9, 2010, 11:57am
5
On Mon, Aug 09, 2010 at 11:53:30AM +0200, Fernando P. wrote:
location ~ /WORD/ {
internal;
root …
}
But it still gets served directly by nginx. I’d like to use it with
X-Accel-Redirect, but first I need to make sure that people can’t access
these files directly.
Could you create a debug log of the request:
http://nginx.org/en/docs/debugging_log.html
?
–
Igor S.
http://sysoev.ru/en/
fipa
August 9, 2010, 12:20pm
6
Finally I managed to make everything work.
“^~” disables regex locaitons testing, so you need something liek this:
I never really understood the docs about that.
But I don’t really understand these ~, ^~ and what have you. They seem
to affect other locations which is not obvious at first sight.
Thanks for your impressive support Igor.
fipa
August 9, 2010, 1:06pm
7
On Mon, Aug 09, 2010 at 12:20:13PM +0200, Fernando P. wrote:
Finally I managed to make everything work.
“^~” disables regex locaitons testing, so you need something liek this:
I never really understood the docs about that.
But I don’t really understand these ~, ^~ and what have you. They seem
to affect other locations which is not obvious at first sight.
http://wiki.nginx.org/NginxHttpCoreModule#location
–
Igor S.
http://sysoev.ru/en/
fipa
August 9, 2010, 12:04pm
8
On Mon, Aug 09, 2010 at 11:59:02AM +0200, Fernando P. wrote:
}
Is it my /uploads/ location which fits maybe better the request and
confuses nginx?
“^~” disables regex locaitons testing, so you need something liek this:
location ~ /restricted/ {
internal;
root …;
}
location /uploads/ {
root …;
}
–
Igor S.
http://sysoev.ru/en/