title: NGINX 403 Forbidden at Root
body: <p>Setting up a site on AWS Lightsail using the Linux/NGINX install from Bitnami.</p>
  
  <p>The root folder (/opt/bitnami/nginx/html) contains <strong>index.html</strong> as default, everything runs just fine. However, swapping that index file out for <strong>index.php</strong> returns 403 in chrome and logs the following error...</p>
  
  <pre><code>*42 directory index of "/opt/bitnami/nginx/html/" is forbidden
  </code></pre>
  
  <p>Index.php is executing just <code>&lt;?php phpinfo(); ?&gt;</code>.</p>
  
  <p>Index.php is accessible in the browser by pointing to its path directly (site.com/index.php)</p>
  
  <p>The contents of my config file <strong>nginx.conf</strong> are unmodified and as follow...</p>
  
  <pre><code>user  daemon daemon;
  worker_processes  auto;
  
  error_log  "/opt/bitnami/nginx/logs/error.log";
  
  events {
      use                 epoll;
      worker_connections  1024;
      multi_accept        on;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
      proxy_temp_path "/opt/bitnami/nginx/tmp/proxy" 1 2;
      fastcgi_temp_path "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
      scgi_temp_path "/opt/bitnami/nginx/tmp/scgi" 1 2;
      uwsgi_temp_path "/opt/bitnami/nginx/tmp/uwsgi" 1 2;
  
      access_log  "/opt/bitnami/nginx/logs/access.log";
  
      sendfile        on;
  
      keepalive_timeout  65;
  
      gzip on;
      gzip_http_version 1.1;
      gzip_comp_level 2;
      gzip_proxied any;
      gzip_vary on;
      gzip_types text/plain
                 text/xml
                 text/css
                 text/javascript
                 application/json
                 application/javascript
                 application/x-javascript
                 application/ecmascript
                 application/xml
                 application/rss+xml
                 application/atom+xml
                 application/rdf+xml
                 application/xml+rss
                 application/xhtml+xml
                 application/x-font-ttf
                 application/x-font-opentype
                 application/vnd.ms-fontobject
                 image/svg+xml
                 image/x-icon
                 application/atom_xml;
  
      gzip_buffers 16 8k;
  
      add_header X-Frame-Options SAMEORIGIN;
  
      ssl_prefer_server_ciphers  on;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS;
  
      include "/opt/bitnami/nginx/conf/bitnami/bitnami.conf";
  
  }
  </code></pre>
  
  <p>the contents of the include "<strong>/opt/bitnami/nginx/conf/bitnami/bitnami.conf</strong>" are as follows...</p>
  
  <pre><code># HTTP server
  
  server {
      listen       80;
      server_name  localhost;
  
      include "/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf";
  
  }
  </code></pre>
  
  <p>the contents of the include "<strong>/opt/bitnami/nginx/conf/bitnami/phpfastcgi.conf</strong>" are as follows...</p>
  
  <pre><code>location ~ \.php$ {
      root           html;
      fastcgi_read_timeout 300;
      fastcgi_pass   unix:/opt/bitnami/php/var/run/www.sock;
  
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME $request_filename;
      include        fastcgi_params;
  }
  </code></pre>
  
  <p>Note: I also tried adding <code>index    index.php</code> to the above.
  Any ideas as to what might be going on here?</p>
  
  <p><strong>NOTE:</strong> Troubleshooting, i tried a stripped alternative to the <strong>nginx.config</strong> file referenced above, which resolved the 403 error but wouldn't do anything other than download the index.php file when visiting the root... </p>
  
  <pre><code>user  daemon daemon;
  worker_processes  auto;
  
  error_log  "/opt/bitnami/nginx/logs/error.log";
  
  
  
  events {
      use                 epoll;
      worker_connections  1024;
      multi_accept        on;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
      client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
      proxy_temp_path "/opt/bitnami/nginx/tmp/proxy" 1 2;
      fastcgi_temp_path "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
      scgi_temp_path "/opt/bitnami/nginx/tmp/scgi" 1 2;
      uwsgi_temp_path "/opt/bitnami/nginx/tmp/uwsgi" 1 2;
  
      access_log  "/opt/bitnami/nginx/logs/access.log";
  
      sendfile        on;
  
      keepalive_timeout  65;
  
      server {
          listen       80;
          server_name  localhost;
  
          location / {
              root   html;
              index  index.php;
          }
  
      }
  
  }
  </code></pre>