title: Nginx :allow folder access only from localhost
body: <p>I have a folder named <code>admin</code> which is in the <code>var/www/html</code> directory.</p>
  
  <p>I want to access that folder from the public internet ie allows access only from localhost.</p>
  
  <p>For that </p>
  
  <p>1) Created a file <code>whitelist-admin</code> in the <code>sites-available</code> directory and added the following.</p>
  
  <pre><code>server{
  
  location ~ /admin/.*\.php$ {
       allow 127.0.0.1;
       try_files $uri $uri/ /index.php;
       deny all;
    }
  
  }
  </code></pre>
  
  <p>When I access <code>&lt;public-ip&gt;/admin</code> I am getting <code>403</code> error but the link <code>&lt;public-ip&gt;/admin/index.php</code> is working I want to disable it.</p>