详解Linux屏蔽浏览器上http请求警报的方法
时间:2023-06-10 18:48:12
众所周知,在Linux系统中浏览器的页面上是不允许出现http请求的,如果出现了http请求就会发生错误,并且Linux系统会向用户发出警报。下面,小编就给大家详解Linux屏蔽浏览器上http请求警报的方法。
警报代码
Mixed Content: The page at ‘https://www.taobao.com/‘ was loaded over HTTPS, but requested an insecure image ‘http://g.alicdn.com/s.gif’。 This content should also be served over HTTPS.HTTPS
Linux
改造之后,我们可以在很多页面中看到如下警报:
很多运营对 https 没有技术概念,在填入的数据中不免出现 http 的资源,体系庞大,出现疏忽和漏洞也是不可避免的。
解决方法
CSP设置upgrade-insecure-requests
好在 W3C 工作组考虑到了我们升级 HTTPS 的艰难,在 2015 年 4 月份就出了一个 Upgrade Insecure Requests 的草案,他的作用就是让浏览器自动升级请求。
在我们服务器的响应头中加入:
header(“Content-Security-Policy: upgrade-insecure-requests”);
我们的页面是 https 的,而这个页面中包含了大量的 http 资源(图片、iframe等),页面一旦发现存在上述响应头,会在加载 http 资源时自动替换成 https 请求。可以查看 google 提供的一个 demo:
Linux
不过让人不解的是,这个资源发出了两次请求,猜测是浏览器实现的 bug:
当然,如果我们不方便在服务器/Nginx 上操作,也可以在页面中加入 meta 头:
《meta http-equiv=“Content-Security-Policy” content=“upgrade-insecure-requests” /》
目前支持这个设置的还只有 chrome 43.0,不过我相信,CSP 将成为未来 web 前端安全大力关注和使用的内容。而 upgrade-insecure-requests 草案也会很快进入 RFC 模式。
从 W3C 工作组给出的 example,可以看出,这个设置不会对外域的 a 链接做处理,所以可以放心使用。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
笔记本电脑合起屏幕进入睡眠怎么办 设置休眠的操作方法
![](https://img.aspxhome.com/file/2023/4/a305985_0s.jpg)
editplus如何插入html表格
![](https://img.aspxhome.com/file/2023/9/a341199_0s.png)
win7系统怎么怎么实现长定时?
![](https://img.aspxhome.com/file/2023/28/a241513_0s.jpg)
Win10系统右键没有“以管理员身份运行”怎么恢复?
![](https://img.aspxhome.com/file/2023/26/a224868_0s.jpg)
Excel计算退休时间的方法和实例介绍(男60女55岁为参考)
WORD文档里如何添加快捷键?
![](https://img.aspxhome.com/file/2023/1/19031_0s.jpg)
WPS网页版怎么退出登录?
![](https://img.aspxhome.com/file/2023/9/a184379_0s.png)
WPS Excel表格中左上角绿三角怎么去掉
![](https://img.aspxhome.com/file/2023/5/a186615_0s.jpg)
Excel EXPONDIST 函数 使用实例教程
![](https://img.aspxhome.com/file/2023/4/a162344_0s.png)
电脑打开设置提示该文件没有与之关联的程序来执行该操作怎么办?
![](https://img.aspxhome.com/file/2023/25/a218134_0s.png)
WinXP 系统安装图文教程(中)
![](https://img.aspxhome.com/file/2023/5/a318993_0s.jpg)
Win11系统BackgroundTaskHost.exe系统错误如何修复?
![](https://img.aspxhome.com/file/2023/28/a239907_0s.png)
在Word2003中制作表格的图文教程
![](https://img.aspxhome.com/file/2023/3/29943_0s.jpg)
wps表格怎么样锁定表头
WPS文如何添加删除线
word中的表格排序数据处理功能
![](https://img.aspxhome.com/file/2023/5/33015_0s.jpg)
wps文字的背景怎么打印
win7系统戴尔笔记本电脑突然关机的多种原因及解决方法
![](https://img.aspxhome.com/file/2023/28/a243821_0s.jpg)
qq健康中心要怎么用?qq健康中心的使用教程
![](https://img.aspxhome.com/file/2023/8/a337369_0s.jpg)
在Safari浏览器中如何添加、整理和查看“个人收藏”书签
![](https://img.aspxhome.com/file/2023/6/a207086_0s.jpeg)