title: Nginx: Restrict access by IP with exception on some routes
body: <p>I would like to know if it's possible to restrict by IP some ressources:
  I want to allow a root pattern to everybody , and I want to restrict all roots to some IP and subnet.</p>
  
  <p>In my nginx conf, I put this:</p>
  
  <pre><code>#1 allow pdf files access to all
  location ~* /\.pdf$ {
    allow all;
  }
  
  #2 restrict to these networks
    allow &lt;ip1&gt;;
    allow &lt;network1&gt;/22;
    allow &lt;network2&gt;/23;
  
  #3 deny all other network
    deny  all;
  </code></pre>
  
  <hr>
  
  <p>When I'm trying to connect from ips different of block #2, I get an access denied.
  How could I do to access pdf files from different IP of block #2 ?</p>