2

I have the following location block in nginx:

location /stats {
  allow 127.0.0.1;
  deny all;
}

If I try and view /stats from my home MacBook I get 403 Forbidden as expected. However, if I view /stats/index.php I am able to view it. I was under the impression the location /stats would apply recursively (i.e. to all children).

How do I make this location block behave as expected?

Thanks.

8

You need to specify location 'beginning with':

location ^~ /stats {
  allow 127.0.0.1;
  deny all;
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.