title: nginx deny access to root and all subfolders
body: <p>I'm using:</p>
  
  <pre><code>location / {
  # IPv6 allow
  allow IPv6 address 1;
  allow IPv6 address 2;
  # IPv4 allow
  allow IPv4 address 1;
  allow IPv4 address 2;
  # deny
  deny all;
  try_files $uri $uri/ /index.php$is_args$args;
  }
  </code></pre>
  
  <p>This does have the expected effect (blocking all except allowed IPs) but only for the root "/".</p>
  
  <p>If an IP that is not allowed goes to <a href="https://www.example.com" rel="nofollow noreferrer">https://www.example.com</a> it is blocked (403 error) but if it goes to <a href="https://www.example.com/subfolder" rel="nofollow noreferrer">https://www.example.com/subfolder</a> it would be allowed.</p>
  
  <p>I would like to extend this match to disallow access to all subfolders and I would like to do that without naming those subfolders (as there are thousands :) ).</p>
  
  <p>Anyone know how this can be done?</p>