php directory index is 403 forbidden with nginx and php-fpm

334
January 07, 2018, at 1:24 PM

I followed the instructions on the arch linux wiki to get a site running using nginx + php and without using apache webserver. For some reason, I'm getting the 403 forbidden error when I try to access the directories that I set up in the nginx config. Here's the config:

server {
  server_name myserver.me;
    location /webmail {
        alias /usr/share/webapps/roundcubemail;
        access_log /var/log/nginx/roundcube_access.log;
        error_log /var/log/nginx/roundcube_error.log;
    }
    # Robots file
    location ~ ^/webmail/robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    # Deny Protected directories 
    location ~ ^/webmail/(config|temp|logs)/ {
         deny all;
    }
    location ~ ^/webmail/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
        deny all;
    }
    location ~ ^/webmail/(bin|SQL)/ {
        deny all;
    }
    # Hide .md files
    location ~ ^/webmail/(.+\.md)$ {
        deny all;
    }
    # Hide all dot files
    location ~ ^/webmail/\. {
        deny all;
        access_log off;
        log_not_found off;
    }
    #Roundcube fastcgi config
    location ~ /webmail(/.*\.php)$ {
        include fastcgi.conf;
        fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
        fastcgi_split_path_info ^/webmail/(.+\.php)(/.*)$;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /usr/share/webapps/roundcubemail/$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PHP_VALUE open_basedir="/tmp/:/var/cache/roundcubemail:/usr/share/webapps/roundcubemail:/etc/webapps/roundcubemail:/usr/share/pear/:/var/log/roundcubemail";
    }
}

}

Why am I getting this error? It's saying that the directory index is forbidden. I know this is a common problem, but I have little php experience, especially with nginx.

Rent Charter Buses Company
READ ALSO
How can I check if there is a certain value in the mySQL server database?

How can I check if there is a certain value in the mySQL server database?

I have a select option form in php/htmlIn the selection option forms I put php like this:

164
PHP - Date and time variable in Australia Timezone

PHP - Date and time variable in Australia Timezone

I log user visits of a page in a separate file and it gets confusing because it's all in a different timezoneTherefore if I'm looking for a user who visited at 1/1/18 at xx

160
Isolate section of a string with repeated words

Isolate section of a string with repeated words

I am trying to isolate (extract) a section from file paths and namesThe problem I am having is its not working when a certain part of the file name is repeated

167