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

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

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

2020.04.06 | 2584閱讀 | 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;

        }

}

贊 (

發表評論

主站蜘蛛池模板: 一本色道久久综合狠狠躁篇| 亚洲精品欧美综合| 99久久国产综合精品网成人影院| 日韩欧美Aⅴ综合网站发布| 国产色婷婷五月精品综合在线| 欧美亚洲日韩国产综合网 | 婷婷色香五月激情综合2020| 天堂久久天堂AV色综合| 天天av天天翘天天综合网| 色8激情欧美成人久久综合电| 日韩亚洲人成在线综合日本| 青青综合在线| 五月丁香综合激情六月久久| 久久久亚洲裙底偷窥综合| 婷婷色香五月综合激激情| 久久亚洲欧洲国产综合| 高清欧美色欧美综合网站| 开心五月激情综合婷婷| 久久久久噜噜噜亚洲熟女综合 | 91成人亚洲综合欧美日韩| 91精品国产91久久综合| 久久久久综合中文字幕| 久久综合色老色| 狠狠色丁香久久婷婷综合_中| 色婷婷综合在线| 色久综合网精品一区二区| 欧美国产日韩另类综合一区| 久久本道久久综合伊人| 久久91精品综合国产首页| 99久久婷婷国产综合精品草原| 久久一本综合| 天天看天天摸色天天综合网| HEYZO无码综合国产精品| 五月丁香综合激情六月久久| 91精品国产综合久久香蕉 | 国产综合色在线视频区| 久久一日本道色综合久久| 色爱区综合激情五月综合色| 色狠狠色狠狠综合天天| 亚洲中文字幕无码久久综合网| 久久婷婷五月综合成人D啪|