Loading

报错:Mixed Content: The page at 'https://www.xxx.com' was loaded over HTTPS, but requested an insecure script 'http://www.xxx.com/'. This request has been blocked; the content must be served over HTTPS.

nginx 代理后报 Mixed Content: The page at 'https://www.xxx.com'

原因:一个https的网站中,混合着http请求,导致报错。
查看结果是前端的请求后台引起,修改前端请求连接,让其也基于http的域名请求即可,跳转经过Nginx。

解决办法

在location 里面添加add_header Content-Security-Policy upgrade-insecure-requests即可


http {
    ...................

    server {
             #listen 443 ssl default_server;
             #listen [::]:443 ssl default_server;#新增这两个


             ssl_certificate pem;  #需要将cert-file-name.pem替换成已上传的证书文件的名称。
             ssl_certificate_key .key; #需要将cert-file-name.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;
    
             server_name  .com;
                location / {
                   .................
                   proxy_pass http:// xx:80;      
                   add_header Content-Security-Policy upgrade-insecure-requests;
                   index index.html index.htm index.jsp index.php;
                }
        }
        server {
            listen 80;
            server_name  ;
        }
}
posted @ 2022-05-06 14:02  Rzk  阅读(5838)  评论(0编辑  收藏  举报