Reputation: 6729
I need to deny all access to most files in a specific folder with Nginx
Here is my configuration that i tried.
location ~ /rapidleech/(classes|configs|files|hosts|languages|rar|templates) {
deny all;
}
location /rapidleech/files/files.lst {
allow all;
}
Info : rapidleech folder contain classes(folder) , configs(folder) ....
Nginx seems to ignore the allow all;
as i get 403 forbidden when trying to access
/rapidleech/files/files.lst
Any help is appreciated..
Upvotes: 0
Views: 114
Reputation: 14344
That because regexp location take precedence over normal location. Read documentation about how nginx choose best matching location.
In your case you could prevent checking regexp location by using ^~
modifier:
location ~ /rapidleech/(classes|configs|files|hosts|languages|rar|templates) {
deny all;
}
location ^~ /rapidleech/files/files.lst {
allow all;
}
Also, you should realize, that regexp locations match against any part of request, not only the beginning, so your configuration prevent access to /some/path/rapidleech/classes
as well.
If it's possible to forbid all the /rapidleech/
tree, it would be simpler and more efficient.
location /rapidleech/ {
deny all;
}
location /rapidleech/files/files.lst {
allow all;
}
Upvotes: 1