Home  >  Article  >  Backend Development  >  Nginx ssl设置后自动下载根目录的index.php而不是载入

Nginx ssl设置后自动下载根目录的index.php而不是载入

WBOY
WBOYOriginal
2016-06-06 20:38:161437browse

碰到了一个奇怪的小白问题,通过如下配置在nginx上配置ssl后,用https访问主页的话,浏览器直接下载index.php,而不是载入index.php,nginx启动无报错还请各位高手指教,多谢。

<code>  server
      {
        root       /var/www/html;
        index      index.html index.htm index.php;

    listen     443;
    server_name        localhost;
    ssl                on;
    ssl_certificate    a.crt;
    ssl_certificate_key        a.key;
    ssl_session_timeout        10m;
    ssl_session_cache shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers                ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP;
    ssl_prefer_server_ciphers  on;

  }
</code>

回复内容:

碰到了一个奇怪的小白问题,通过如下配置在nginx上配置ssl后,用https访问主页的话,浏览器直接下载index.php,而不是载入index.php,nginx启动无报错还请各位高手指教,多谢。

<code>  server
      {
        root       /var/www/html;
        index      index.html index.htm index.php;

    listen     443;
    server_name        localhost;
    ssl                on;
    ssl_certificate    a.crt;
    ssl_certificate_key        a.key;
    ssl_session_timeout        10m;
    ssl_session_cache shared:SSL:10m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers                ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP;
    ssl_prefer_server_ciphers  on;

  }
</code>

和 SSL 没有关系,请确认:

  • 这个请求的确匹配到了这个 server 而不是别的
  • 这个 server 的配置的其他部分指明了如何处理 .php 文件(发往 php-fpm)

继续顶。。。

你的程序遇到https://xxx.com/111.html是可以的访问的(不考虑伪静态)

但访问.php后缀却无法正确执行

说明你的nginx与php没有关联

我对你们在网上回答的答案感到很疑惑,你们确定遇到这个问题吗?
我把VPS关闭了快4个小时,然后开网站一样会下载index.php。更别说是因为SSL还是https还是php还是nginx了,我恢复以前的正常快照一样会碰到这个问题。
ipconfig /flushdns 重启电脑、手机3G访问,一样会下载这玩意,我就纳闷了,CDN缓存这么久都不失效。。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn