title: Allow access to index.php and one public directory only, with nginx
body: <p>I want to allow free access to <code>/index.php</code> as well as <code>/public folder</code> and all its subdirs. Unfortunately, whatever I try, <strong>Nginx</strong> still denying connection, for either me or my scripts (nested in the html template, they need to access to the public folder in order to get some ressources like <code>css</code>).</p>
  
  <p>I get a <code>403</code> when I try to open <code>public</code>, like all other paths. However, everything is good with index.php (access is allowed). The Nginx process is handled by www-data, public folder has all good rights. Do I miss something? </p>
  
  <p>Here is my nginx configuration :</p>
  
  <pre><code>server {
  
          server_name dev;
  
          listen  80;
          listen  [::]:80 ipv6only=on;
  
          return  301 https://$server_name$request_uri;
  
  }
  
  server {
  
          fastcgi_buffers 8 16k;
          fastcgi_buffer_size 32k;
          fastcgi_connect_timeout 300;
          fastcgi_send_timeout 300;
          fastcgi_read_timeout 300;
  
          server_name dev;
          listen 443 default_server ssl;
         ssl on;
          ssl_certificate ssl/dev.cert;
          ssl_certificate_key ssl/dev.nopass.key;
          ssl_session_timeout 5m;
          #ssl_protocols TLSv1;
          ssl_prefer_server_ciphers on;
          ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP;
  
          root /var/www/awesomeProject;
          index index.php;
  
          # deny everything that doesn't match another location
          location / { deny all; }
  
          location = / { } # need to allow GET / to internally redirect to /index.php
  
          location /index.php {
                  include snippets/fastcgi-php.conf;
                  fastcgi_pass unix:/tmp/php.sock;
          }
  
  location = /public { allow all; }
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/RhXkp.png" alt="enter image description here"></p>