龍巖易富通網絡科技有限公司

龍巖小程序開發,龍巖分銷系統

NGINX下升級HTTPS錯誤:Mixed Content: The page at ‘https://XXX’ was loaded over HTTPS, but requested an ins

2020.04.06 | 2433閱讀 | 0條評論 | 服務器配置

提示或報錯:


Mixed Content: The page at 'https://www.example.com' was loaded over HTTPS, but requested an insecure image ‘http://static.example.com/test.jpg’. This content should also be served over HTTPS.

首先,為了解決樣式問題,我在前端頁面,引入了一個meta


<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

等效于用PHP設置頭部


header("Content-Security-Policy: upgrade-insecure-requests");

這樣導致了一個問題,我的測試環境下并沒有ssl證書,因此又冒出很多問題。


后面在nginx上做處理。一個nginx的配置


server {

        listen       443;

        server_name  www.example.com;

        #charset koi8-r;


        error_log  /logs/nginx/error.log;

        root /var/www/www.example.com;

        index  index.php index.html index.htm;

        ssl on;

        ssl_certificate   cert/test/test.pem;

        ssl_certificate_key  cert/test/test.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;


        add_header  X-Frame-Options  deny;

        add_header  X-Content-Type-Options  nosniff;

        add_header  X-XSS-Protection "1; mode=block";

        add_header Strict-Transport-Security max-age=86400;

        add_header Content-Security-Policy "upgrade-insecure-requests;default-src *;script-src 'self' https://static.example.com http://static.example.com 'unsafe-inline' 'unsafe-eval';style-src https://static.example.com http://static.example.com 'self' 'unsafe-inline';frame-src 'self';connect-src 'self';img-src https://static.example.com http://static.example.com data: blob: 'self'";


        location / {

                if (!-f $request_filename){

                        rewrite ^/(.*)$ /index.php?s=$1 last;

                        break;

                }

                limit_except GET POST DELETE PUT {

                        deny all;

                }

        }



        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

                        root   html;

        }


        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ \.php$ {

                        fastcgi_pass   127.0.0.1:9000;

                        fastcgi_index  index.php;

                        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

                        include        fastcgi_params;

        }


        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        location ~ /\.ht {

                        deny  all;

        }

}

贊 (

發表評論

主站蜘蛛池模板: 久久综合久久综合亚洲| 国产天天综合永久精品日| 亚洲综合色区在线观看| 欧美国产综合欧美视频| 婷婷五月综合激情| 欧美激情综合五月色丁香| 色综合久久88色综合天天 | 综合亚洲欧美三级| 色综合久久中文色婷婷| 国产91色综合久久免费| 亚洲色偷偷狠狠综合网| av色综合久久天堂av色综合在| 午夜激情影院综合| 亚洲欧美日韩综合二区三区| 久久天天日天天操综合伊人av| 亚洲欧洲日韩国产综合在线二区 | 观看 亚洲欧美日韩综合在线一区 高清欧美色欧美综合网站 | 色综合色综合色综合色欲| 国产综合欧美| 亚洲情综合五月天| 久久本道综合久久伊人| 国产美女亚洲精品久久久综合| 老色鬼久久亚洲AV综合| 国产91色综合久久免费| 国产综合久久久久久鬼色| 曰韩人妻无码一区二区三区综合部| 亚洲国产成人久久综合碰碰动漫3d| 色噜噜狠狠成人中文综合| 亚洲人成依人成综合网| 日韩欧美亚洲综合久久影院Ds| 色与欲影视天天看综合网| 色欲久久久天天天综合网精品| 欧美色综合天天综合高清网| 丁香色欲久久久久久综合网| 亚洲色欲久久久综合网| 亚洲AV综合色区无码一区| 国产成人AV综合久久| 丁香五月天综合缴情网| 激情综合婷婷丁香五月| 狠狠88综合久久久久综合网| 婷婷亚洲综合五月天小说|