restrict access to a certain url prefix

Eventually I resolved this issue using a negative regex. In my question I used the location and the regex incorrectly, as I never told nginx what to do with the path I wrote.

So in order to restrict access to anything that doesn’t start with /myapp/path use:

location ~ ^/(?!myapp/path) { return 404; } # Or deny all;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top