-1

My question is very simple, but I can't find simple answer on this forum or Google...

How to restrict access to all subdirs in Nginx ? I can only restrict access to the exact path:

location /wiki/data  {
    deny all;
}

This is ok for the data folder, but not for the subdirs of data... Could you help me ?

  • The pathname parameter in a [`location`](http://nginx.org/en/docs/http/ngx_http_core_module.html#location) is a prefix string that should match should match **everything that starts with that path, so for instance `/wiki/data/file.dat` and `/wiki/data/sub/dir/` should be matched and blocked. – HBruijn May 30 '16 at 16:13

1 Answers1

0

A quick google search for wild card nginx location will give you the answer to this. Use a ~ or ~* to indicate a case sensitive or insenstive match respectively then give the regular expression. In your case.

location ~ /wiki/data/*

should work although I haven't tested it.

Catherine MacInnes
  • 1,958
  • 11
  • 15