Forbidden location when using alias in nginx for relative urls -


i trying set roundcube / phpldapadmin / ... nginx on relative urls, e.g.:

example.com/roundcube example.com/phpldapadmin 

first of all, working fine apache 2.4. have following folders:

# roundcube /var/www/roundcube # phpldapadmin /usr/share/phpldapadmin 

i have following location 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, following phpldapadmin 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 403 forbidden, following logs:

2016/02/07 21:43:33 [error] 23047#0: *1 directory index of "/usr/share/phpldapadmin/htdocs"  forbidden, client: xxx.xxx.xxx.xxx, server: ****, request: "get /phpldapadmin/ http/1.1",  host: "****" 

i checked 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 owner :www-data did not work. when tried following roundcube did not work:

location /roundcube/ {     alias /var/www/roundcube;     ... } 

i thinking problem trailing /, or similar, new nginx can't find it...

basically, have inverse problem of question : https://stackoverflow.com/questions/31820362/nginx-403-directory-is-forbidden-when-using-root-location

the location , alias should both have trailing / or neither have trailing /. in case, should using root instead of alias both location blocks.

location /roundcube {     root /var/www;     index index.php;      location ~ \.php$ {         try_files $uri =404;          fastcgi_pass unix:/var/run/php5-fpm.sock;          include /etc/nginx/fastcgi_params;         fastcgi_param script_filename $document_root$fastcgi_script_name;     } }  location /phpmyadmin {     root  /usr/share;     index  index.php index.html index.htm;      location ~ \.php$ {         try_files $uri =404;          fastcgi_pass unix:/var/run/php5-fpm.sock;          include /etc/nginx/fastcgi_params;         fastcgi_param script_filename $document_root$fastcgi_script_name;     } } 

the fastcgi_index not in location matches .php (see this document).

the script_filename parameter needed in both blocks (or neither if in /etc/nginx/fastcgi_params).


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -