我试图使用一个子文件夹来包含我的服务器上的Web应用程序。 例如:example.com/netdata ===> Netdata monitoring example.com/passbolt ====>密码pipe理器等。
为了使事情工作我已经使用这个configuration:
#Passbolt server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/key.pem; allow all; root /var/www/html/; server_name passbolt.local; location /passbolt/ { alias /var/www/html/passbolt/app/webroot/; try_files $uri $uri/ /index.php?$args; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } } }
但我总是有一个403 forbiden错误,所以我已经检查了每个文件的权限,但所有这些都是由www-data所拥有,这是我的nginx服务器的用户。
我在Debian 8上。
任何人都可以帮助我?
编辑1:在日志中我得到这个错误:
2017/04/24 16:07:08 [error] 28301#0: *2 directory index of "/var/www/html/passbolt/app/webroot/" is forbidden, client: 192.168.122.1, server: passbolt.local, request: "GET /passbolt/ HTTP/1.1", host: "passbolt.local"
添加这个:
location / { index index.htm index.html index.php index.py index.cgi index.sh; }
好,所以我find了一个解决scheme。 我的应用程序正在与cakephp和这个框架,你需要照顾的URL重写和其他类似的东西。
这里是我在Nginx中的configuration来使事情工作:
#Passbolt server { listen 80 default_server; listen [::]:80 default_server; listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl_certificate /etc/nginx/ssl/cert.pem; ssl_certificate_key /etc/nginx/ssl/key.pem; root /var/www/html/; server_name passbolt.local; location /passbolt { if (-f $request_filename) { break; } # Avoid recursivity if ($request_uri ~ /webroot/index.php) { break; } rewrite ^/passbolt$ /passbolt/ permanent; rewrite ^/passbolt/app/webroot/(.*) /passbolt/app/webroot/index.php?url=$1 last; rewrite ^/passbolt/(.*)$ /passbolt/app/webroot/$1 last; location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } }
非常感谢您的帮助!