amh面板nginx配置https后访问PHP文件直接下载
高洛峰
高洛峰 2016-11-01 09:44:18
0
1
2442

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

1.png

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

1.png

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

1.png

1.png

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

1.png

https直接下载:

1.png

环境是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)由下载变成了如下:

1.png

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

1.png

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

补充:原来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了:

1.png

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

1.png

原有页面应该是这样的:

1.png

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

1.png

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全員に返信(1)
三叔

nginx 配置问题 需要支持php文件运行 你的静态文件应该是可以运行的

いいねを押す +0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!