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

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

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

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

        }

}

贊 (

發表評論

主站蜘蛛池模板: 亚洲 欧美 日韩 综合aⅴ视频| 欧美va亚洲va国产综合| 国产成人亚洲综合无码精品| 婷婷色香五月激情综合2020| 综合人妻久久一区二区精品| 国产色综合久久无码有码| 亚洲成A人V欧美综合天堂麻豆| 亚洲啪啪综合AV一区| 丁香五月缴情综合网| 久久综合亚洲欧美成人| 婷婷五月六月激情综合色中文字幕| 日日AV色欲香天天综合网| 国产精品综合久成人| 色婷婷综合和线在线| 久久一日本道色综合久久| 国产亚洲欧洲Aⅴ综合一区| 狠狠色婷婷综合天天久久丁香| 色婷婷综合久久久久中文字幕| 天天久久狠狠色综合| 欧美婷婷六月丁香综合色| 亚洲偷自拍拍综合网| 亚洲综合色婷婷七月丁香| 色爱无码AV综合区| 在线综合亚洲欧美日韩| 国产成+人+综合+欧美亚洲| 久久婷婷五月综合色高清| 中文字幕亚洲综合精品一区| 夜鲁鲁鲁夜夜综合视频欧美| 国产在线一区二区综合免费视频| 情人伊人久久综合亚洲| 伊人久久综合热线大杳蕉下载| 伊人久久综合精品无码AV专区| 天天影视色香欲综合久久| 久久精品国产亚洲综合色| 综合久久国产九一剧情麻豆| 婷婷综合另类小说色区| 色综合综合色综合色综合| 国产成人精品综合在线观看| 亚洲综合熟女久久久30p| 亚洲国产综合专区在线电影| 日日狠狠久久偷偷色综合免费|