Forum: NGINX deny directory abc denies directory abcd etc

Posted by edtaa (Guest)
on 2012-08-07 19:31
(Received via mailing list)
Hi
I'm new to this forum so I hope this hasn't come up before I didn't find
anything by searching.

I'm using the following to block access to multiple directories:

location ~ /(abc|def|ghi) { deny  all; access_log off; log_not_found
off; return 404;}

The problem I find is that if there is a file or directory beginning
with the same three characters, it too is blocked. So, for example, a
directory or file named abcd would also be blocked.

Is there a solution to this or is my code incorrect?

Thanks

Terry

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,229406,229406#msg-229406
Posted by Cliff Wells (Guest)
on 2012-08-07 21:09
(Received via mailing list)
On Tue, 2012-08-07 at 13:30 -0400, edtaa wrote:
> Hi
> I'm new to this forum so I hope this hasn't come up before I didn't find
> anything by searching.
>
> I'm using the following to block access to multiple directories:
>
> location ~ /(abc|def|ghi) { deny  all; access_log off; log_not_found
> off; return 404;}
>

Regex locations take precedence over literal locations.  Change your
regex to this:

location ~ /(abc|def|ghi)/?$

Cliff
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.