Nginx 与 HTTPS:// 继续下载 /index.php 但其他一切正常

Nginx 与 HTTPS:// 继续下载 /index.php 但其他一切正常

我已经安装了 nginx,并将服务器从 apache 转移到 nginx。我创建了一个具有 SSL 的子域。我的 http:// 运行正常。但是当我访问https://secure.gamegambit.com它开始下载文件。但是其他任何带有 https:// 的 URL 都可以正常工作,例如https://secure.gamegambit.com/gamegambit-wiki.html

nginx 默认配置:

server {
listen 443;
server_name secure.gamegambit.com;
root /var/www/;
index index.php index.html index.htm default.html default.htm;

ssl on;
ssl_certificate /root/gamegambit.crt;
ssl_certificate_key /root/gamegambit.key;
ssl_client_certificate /root/gs_intermediate_ca.crt;

ssl_session_timeout 5m;

ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;

## Default location
location / {
    try_files $uri $uri/ /index.php?q=$request_uri;

}

location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
  access_log        off;
  expires           30d;
  root /var/www/;
}
    location ~ .*.php$ {
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
 location ~ /.ht {
    deny  all;
    }
 location ~ /.git {
    deny  all;
 }
    location ~ /.svn {
        deny  all;
 }
location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
            return 403;
            error_page 403 /403_error.html;
    }
# caching of files 
    location ~* \.(ico|pdf|flv)$ {
            expires 1y;
    }
location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
            expires 14d;
    }
}

我的 /etc/nginx/fastcgi_params

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param SERVER_PROTOCOL $server_protocol; 
fastcgi_param SCRIPT_NAME $fastcgi_script_name; 
fastcgi_param PATH_INFO $fastcgi_script_name; 
fastcgi_param REQUEST_URI $request_uri; 
fastcgi_param DOCUMENT_URI $document_uri; 
fastcgi_param DOCUMENT_ROOT $document_root; 
fastcgi_param REMOTE_ADDR $remote_addr; 
fastcgi_param REMOTE_PORT $remote_port; 
fastcgi_param SERVER_ADDR $server_addr; 
fastcgi_param SERVER_PORT $server_port; 
fastcgi_param SERVER_NAME $server_name; 
fastcgi_param QUERY_STRING $query_string; 
fastcgi_param REQUEST_METHOD $request_method; 
fastcgi_param CONTENT_TYPE $content_type; 
fastcgi_param CONTENT_LENGTH $content_length; 
fastcgi_param REDIRECT_STATUS 200;

答案1

php 文件的位置指令应如下所示:

location ~ \.php$
{
   ...
}

请查看本教程以了解完整的设置细节和配置设置:

http://www.idolbin.com/blog/server-management/vps-setup-guide/enable-https-httpssl-in-nginx-web-server/

相关内容