Fwd: Deny access to subfolder/files

itpp2012 nginx-forum at nginx.us
Fri Feb 13 19:10:10 UTC 2015


basti Wrote:
-------------------------------------------------------
> Hello,
> 
> i have a URL like
> 
> https://example.com/foo/doc/bar/filename.txt
> 
> I want to deny access to all files and folders in /doc/...
> and try

> location ~ ^/foo/(doc|etc|lib|log|sbin|var/cache|var/lib|var/log)/ {
>   deny all;
> }

Maybe something like:

map $uri $locn {
  default  0;
  ~*/foo/   1;
  ~*/doc/  1;
}

location / {
if ($locn) { return 404; }
}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,256652,256663#msg-256663



More information about the nginx mailing list