How to deny access to a folder, but allow access to every subfolders (wildcard)

B.R. reallfqq-nginx at yahoo.fr
Fri Jan 9 19:03:42 UTC 2015


nginx provides a prefix to match exact URIs:
location = /members {
    deny all;
}

All the different prefixes and their use can be found in the location
<http://nginx.org/en/docs/http/ngx_http_core_module.html#location>
directive documentation.

You do not need to set any location for "/members/.+"-like URIs, unless you
need to specify directives specific to it.
You could then use:
location /members {
    [...]
}
---
*B. R.*

On Fri, Jan 9, 2015 at 2:25 AM, Raúl Galicia <lvqp at sahsanu.com> wrote:

> El 2015-01-09 01:44, carlg escribió:
>
>> Hi,
>>
>> I need to deny access to /members but allow access to every folders below.
>>
>> There may be a lot of folders, maybe a thousan, and each of those folders
>> contain 5 other folders.  So i need a wildcard.
>>
>> Here is what i tried :
>>
>> location ~ ^/members/([^/]+)/([^/?]+)$ { allow all; }            #allow
>> every folders below /members with wildcard
>> location ~ ^/members/ { deny all; }
>> #deny
>> everything else
>>
>> But it doesn't work.
>>
>
>
> Hi,
>
> This works for me... or I think so ;)
>
> location ~* /members/.+/.* { allow all; }
> location ~* /members/.* { deny all; }
>
> Cheers,
> Raúl Galicia
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20150109/e65e42cc/attachment-0001.html>


More information about the nginx mailing list