How to block excluding specific url in nginx?

hi. i have a trouble and question!
my current configuration in nginx is like …
only “/blah/” url can access…

================================
server {
location / {
return 403;
}
location ^~ /blah/ {
proxy_pass http://127.0.0.1:8888;
}
}

but now i have to access “/” location, too
how to block excluding specific url in nginx?

to conclude,
i want to access the only “/” and “/blah/” (for example, aaa.com and
AAA Sorry Page)

can anyone help me?

Posted at Nginx Forum:

On Wed, Nov 26, 2014 at 07:39:58AM -0500, goversation wrote:

Hi there,

but now i have to access “/” location, too
how to block excluding specific url in nginx?

Don’t exclude. Include.

location = / {
# whatever should happen for the request “/”
}

f

Francis D. [email protected]

thanks for replying
but I meant that location allow only “/” and “/blah”
I want to deny the others except “/”
example is as follows

================
abc.com/ = OK
abc.com/blah/ = OK
abc.com/dd = 403
abc.com/… = 403

help me again!

Posted at Nginx Forum:

On Wed, Nov 26, 2014 at 07:24:46PM -0500, goversation wrote:

Hi there,

but I meant that location allow only “/” and “/blah”
I want to deny the others except “/”

Use three locations.

location = / { # allow }
location /blah { # allow }
location / { # deny }

f

Francis D. [email protected]

Make a location that matches each URI exactly and copy-paste content.

As Francis explained, location matches are inclusive, not exclusive,
thus
everything you do not match goes elsewhere.

B. R.

thanks for replying.
but I meant that location allow only “/” and “/blah”.
I want to deny the others except “/” .
example is as follows.

================
abc.com/ = OK
abc.com/blah/ = OK
abc.com/dd = 403
abc.com/… = 403

help me again!

Posted at Nginx Forum:

Thank you for replying.
You’ll get blessed.

Posted at Nginx Forum:

thanks a lot :slight_smile:

Posted at Nginx Forum: