Welcome! Log In Create A New Profile

Advanced

Re: Restricting access to specific subdirectories

Maxim Dounin
February 03, 2013 04:54PM
Hello!

On Sat, Feb 02, 2013 at 10:27:40PM -0500, jdiana wrote:

> Hey all,
>
> I'm a little stumped about what I'm doing wrong here. Basically I have a
> subdirectory that I want to restrict access to specific IP's, otherwise
> return a 403.
>
> If I do the following (inside my server {} block):
>
> server {
> // normal processing code here
> ...
>
> location ~ ^/my_ws$ {
> allow XX.XX.XX.XX;
> allow XX.XX.XX.XX/24;
> deny all;
> }
> }
>
> Hitting the following URL works as intended and I get a 403 if I try from
> anywhere other than the specified URL's: http://www.mydomain.com/my_ws
>
> However, if there's anything AFTER that (i.e. my_ws/, my_ws/page2,
> my_ws?parameter1, etc.) it allows them to proceed regardless of IP.
>
> I'm sure it's something required before or after the $, but I can't figure
> it out.

You don't need regular expressions, just use normal prefix
location:

location /my_ws {
allow ...
deny all;
}


See http://nginx.org/r/location for details.

--
Maxim Dounin
http://nginx.com/support.html

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Restricting access to specific subdirectories

jdiana February 02, 2013 10:27PM

Re: Restricting access to specific subdirectories

GreenGecko February 02, 2013 10:48PM

Re: Restricting access to specific subdirectories

Jonathan Matthews February 03, 2013 06:54AM

Re: Restricting access to specific subdirectories

Maxim Dounin February 03, 2013 04:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 294
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready