部署https后浏览器提示不安全,不出现绿色小锁?
发布时间:2021/3/31 9:51:50
部署https后,浏览器会提示它不安全,并且绿色锁定图标没有出现?
访问网站后,按f12键,浏览器将提示:
混合内容:通过HTTPS加载了位于https://www.xxx.com/上的页面,但请求了不安全的图像http://www.xxx.com/uploads/2018/12/3.png 。此内容
原因是在https页面中,如果调用了http资源,则浏览器将引发一些错误。
解决方案:在头中添加Upgrade-Insecure-Requests,这将告诉浏览器将站点的所有http连接升级为https连接,并保留默认的外部站点请求。
添加标题方法:
1.iis7
image.png
或直接在网站根目录中定义web.config
<?xml版本=“ 1.0”编码=“ UTF-8”?>
<配置>
<system.webServer>
<http协议>
<customHeaders>
<add name =“ Content-Security-Policy” value =“ upgrade-insecure-requests” />
</ customHeaders>
</ httpProtocol>
</system.webServer>
</ configuration>
2.apache
可以直接在网站根目录.htaccess中定义
<IFModule mod_headers.c>
标头添加内容安全策略升级不安全请求
</ IFModule>
3. nginx
服务器 {
听80;
server_name(myservername);
add_header内容安全策略“升级不安全请求”;
地点 / {
proxy_pass http:// localhost:5000;
}
}
本文来源:
[复制链接]