Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have the following location block in nginx:

location /stats {
  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?


share|improve this question

You need to specify location 'beginning with':

location ^~ /stats {
  deny all;
share|improve this answer
You were faster :) – Christopher Perrin Jul 16 '12 at 22:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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