I am trying to set up roundcube / phpldapadmin / ... with Nginx on relative urls, e.g.:
example.com/roundcube
example.com/phpldapadmin
The source are in the following folders:
/var/www/roundcube
/usr/share/phpldapadmin
Everything was working fine with Apache 2.4 but I am new to Nginx. I have the following location
for roundcube
:
location /roundcube/ {
root /var/www;
index index.php;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Which works fine, but the following for phpldapadmin
does not work:
location /phpldapadmin/ {
alias /usr/share/phpldapadmin/htdocs;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
I get a 403 forbidden
, with the following logs:
2016/02/07 21:43:33 [error] 23047#0: *1 directory index of "/usr/share/phpldapadmin/htdocs" is forbidden, client: xxx.xxx.xxx.xxx, server: , request: "GET /phpldapadmin/ HTTP/1.1", host: ""
I checked the permission:
$ namei -om /usr/share/phpldapadmin/htdocs
f: /usr/share/phpldapadmin/htdocs
drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root share
drwxr-xr-x root root phpldapadmin
drwxr-xr-x root www-data htdocs
$ ls -l /usr/share/phpldapadmin/htdocs/index.php
-rw-r--r-- 1 root root 20036 Oct 28 17:32 /usr/share/phpldapadmin/htdocs/index.php
I tried changing the owner to :www-data
but it did not work. When I tried the following for roundcube it did not work:
location /roundcube/ {
alias /var/www/roundcube;
...
}
I am thinking that this is probably a problem with a trailing /
, or something similar, but I am really new to nginx so I can't find it...
Basically, I have the inverse problem of: https://stackoverflow.com/questions/31820362/nginx-403-directory-is-forbidden-when-using-root-location
location
androot
and did not manage to get it working. Withroot
it works well, the problem is that (I forgot to put this in the question... ) I havephpldapadmin
which have its root inphpldapadmin/htdocs
so I cannot useroot
. I managed to get it working by removing thetry_files
instruction after reading thattry_files
andalias
do not work well together. – Subway