我在centos服务器上使用nginx + php-fpm,并且在尝试设置https并修改nginx.conf时,我发现只有'index.php'无法正确访问。
工作:
https://domain/*.php(*!=索引)
不起作用:
我的nginx.conf看起来像这样:
server {
listen 443 default_server;
server_name localhost;
ssl on;
root /home/wwwroot/default;
index index.html index.htm;
ssl_certificate cert/*****.pem;
ssl_certificate_key cert/*****.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /home/wwwroot/default;
index index.html index.htm index.php;
}
location ~ [^/]\.php(/|$) {
root /home/wwwroot/default;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
}
}