问题描述:
Mixed Content: The page at 'https://www.xxx.com/' was loaded over HTTPS,but requested an insecure script 'http://www.xxx.com/a.js'.
This request has been blocked; the content must be served over HTTPS.
解决方案:
修改 nginx 的 proxy 配置部分,如下所示:
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
add_header Content-Security-Policy upgrade-insecure-requests;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
本文解决了一个常见问题:网站从HTTPS加载但请求了不安全的HTTP脚本,导致MixedContent错误。通过修改Nginx的代理配置,添加了多个头信息以确保所有内容都通过HTTPS加载,从而避免了浏览器的安全警告。

1万+

被折叠的 条评论
为什么被折叠?



