2

I have a quite simple setup with nginx and php-fpm, howsoever when I try to access my website with my-website.com I get a 403 forbidden error, If I access my-website.com/index.php everything works fine. This is what's showing up in my log:

a.ipv4.addr.here - user  [14/Dec/2013:11:46:41 +0100] "GET / HTTP/1.1" 403  192 "https://my-website.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"

This is the output of ls -l of the htdocs directory:

drwxr-xr-x 14 www-data www-data 4.0K Dec 12 16:02 htdocs

I am performing a http-redirect to https to force ssl, here's the config:

server {
        listen 80;
        listen [::]:80;

        root /var/www/my-domain.com/htdocs/;
        index index.php index.html index.htm /index.php;

        server_name my-domain.com;
        rewrite     ^   https://$server_name$request_uri? permanent;

}

And here is the Server config listening on Port 443:

server {
        listen 443;
        listen [::]:443;
        server_name my-domain.com;

        root /var/www/my-domain.com/htdocs/;
        index   index.php index.html /index.php;

        access_log /var/log/nginx/my-domain.log;
        ssl on;
        ssl_certificate /etc/ssl/certs/my-domain.com.crt;
        ssl_certificate_key /etc/ssl/private/my-domain.com.key;

        ssl_session_timeout 5m;

        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
        ssl_prefer_server_ciphers on;

        location / {
                try_files $uri $uri/ =404;
                auth_basic              "Restricted:";
                auth_basic_user_file    .htpasswd;
        }


        location ~ \.php$ {

                 auth_basic              "Restricted:";
                 auth_basic_user_file    .htpasswd;
                 fastcgi_pass unix:/var/run/php5-fpm.sock;
                 fastcgi_index index.php;
                 include fastcgi_params;
        }
        #deny access on dotfiles
        location ~ /\. {
                 deny  all;
        }

}

And here is the ls -l output for the index.php:

-rwxr-x--x 1 www-data www-data 2.4K Dec 12 11:11 index.php

1 Answer 1

1

Add index index.php to your location / block, or nginx won't know that you're trying to display index.php by default.

The fastcgi_index option is of no help since it is only considered if the URI ends in .php...

3
  • I'm sorry, but this doesn't work. I now have: location / { index index.php; [...] }
    – Momo
    Dec 14, 2013 at 11:40
  • 1
    Have you made sure that all directories to your http root are accessible for the webserver, too? (/var, /var/www, ...) Dec 14, 2013 at 12:21
  • It was infact a permission issue, thank you for your help!
    – Momo
    Dec 16, 2013 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .