amh面板nginx配置https后访问PHP文件直接下载

查看:105
本文介绍了amh面板nginx配置https后访问PHP文件直接下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

实在找不到解决方法了,google就那一篇文章在好几个地方也不知道谁抄的谁的,关键你抄袭就罢了管用也行啊还不管用:

感觉我遇到的和这个问题里的答案是一样的:
https://segmentfault.com/q/10...

但是这个问题有答主说和ssl无关,那么我访问http的1.php(正常访问)和https的1.php(直接下载)分别如下:

我又访问其他php文件http正常打开:

https直接下载:

环境是amh4.2的nginx,证书是在腾讯云申请的DV证书,nginx.conf的ssl配置如下:

server {
        listen 443;
        server_name www.w00yun.top;
        ssl on;
        ssl_certificate 1_www.w00yun.top_bundle.crt;
        ssl_certificate_key 2_www.w00yun.top.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;
        location / {
            root   /home/wwwroot/w00yun.top/web;
            index  index.html index.htm;
        }
    }

把ssl配置改为:

server {
                listen 443;
                server_name www.w00yun.top;
                ssl on;
                ssl_certificate 1_www.w00yun.top_bundle.crt;
                ssl_certificate_key 2_www.w00yun.top.key;
                ssl_session_timeout 5m;
                ssl_protocols TLSv1;
                ssl_ciphers  HIGH:!aNULL:!MD5;
                ssl_prefer_server_ciphers   on;

                location / {
                        root   /home/wwwroot/w00yun.top/web;
                        index  index.html index.htm index.php;
                }

                location ~ .*\.php$
                {
                        fastcgi_pass unix:/tmp/php-cgi.sock;
                        fastcgi_index index.php;
                        include fcgi.conf;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                {
                        expires      30d;
                }

                location ~ .*\.(js|css)?$
                {
                        expires      12h;
                }

        }

https访问1.php(phpinfo)由下载变成了如下:

但是访问之前的index.php还是直接下载:

想问一下到底是哪里的原因呢?


补充:
原来amh面板有单独的域名配置文件,通过修改域名配置文件如下:

listen 443;
        ssl on;
        ssl_certificate /usr/local/nginx/conf/1_www.w00yun.top_bundle.crt;
        ssl_certificate_key /usr/local/nginx/conf/2_www.w00yun.top.key;

        set $subdomain '';
        root  /home/wwwroot/w00yun.top/web$subdomain;
        include rewrite/amh.conf; #rewrite end

        #error_page
        error_page 400 /ErrorPages/400.html;
        error_page 403 /ErrorPages/403.html;
        error_page 404 /ErrorPages/404.html;
        error_page 502 /ErrorPages/502.html;
        location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
        {
                root /home/wwwroot/w00yun.top/web;
        }


        location ~ .*\.php$
        {
                fastcgi_pass  unix:/tmp/php-cgi-w00yun.top.sock;
                fastcgi_index index.php;
                include fcgi-host.conf;
                fastcgi_param DOCUMENT_ROOT  /web$subdomain;
                fastcgi_param SCRIPT_FILENAME  /web$subdomain$fastcgi_script_name;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
        {
                expires      30d;
        }

        location ~ .*\.(js|css)$
        {
                expires      12h;
        }

已经可以访问部分php文件(自写PHP页面)和phpinfo了:

也可以直接访问url不添加index.php,但是丢失JS和CSS样式:

原有页面应该是这样的:

直接访问url加上index.php仍然会直接下载:

解决方案

已经解决,还是配置文件的问题,修改成以下配置文件:

server {
        listen 443;
        ssl on;
        ssl_certificate 1_www.w00yun.top_bundle.crt;
        ssl_certificate_key 2_www.w00yun.top.key;
    }

一开始也是直接下载,后来感觉可能是缓存问题,然后换了个浏览器就可以了,接着修改了一下文件,谷歌浏览器同样也可以访问了,果然就是缓存的问题= =

这篇关于amh面板nginx配置https后访问PHP文件直接下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆