HTTPS 是 HTTP over Secure Socket Layer,以安全为目标的 HTTP 通道,所以在 HTTPS 承载的页面上不允许出现 http 请求,一旦出现就是提示或报错:

jquery.min.js: Mixed Content: The page at 'https://www.qqzsh.top/getDetail?id=44' was loaded over HTTPS, but requested an insecure image 'http://images.qqzsh.top/41403a8d69464a67b8aedeb3dbe70d18'. This content should also be served over HTTPS.

很多运营对 https 没有技术概念,在填入的数据中不免出现 http 的资源,出现疏忽和漏洞也是不可避免的。

解决办法一:CSP设置upgrade-insecure-requests

W3C工作组考虑到了我们升级HTTPS的艰难,在2015年4月份就出了一个Upgrade Insecure Requests 的草案(http://www.w3.org/TR/mixed-content/),他的作用就是让浏览器自动升级请求。
在我们服务器的响应头中加入:

server {
...
add_header Content-Security-Policy upgrade-insecure-requests;
...
}

插入nginx配置文件中也可以。

我们的页面是 https 的,而这个页面中包含了大量的 http 资源(图片、iframe等),页面一旦发现存在上述响应头,会在加载 http 资源时自动替换成 https 请求。

方法二、
页面中加入 meta 头:

<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" />

目前支持这个设置的还只有 chrome 43.0,不过我相信,CSP 将成为未来 web 前端安全大力关注和使用的内容。而 upgrade-insecure-requests 草案也会很快进入 RFC 模式。

This content should also be served over HTTPS的更多相关文章

  1. 网页中嵌入百度地图报错:The request has been blocked,the content must served over Https

    网页中嵌入百度地图 1.进入百度地图开发平台:http://lbsyun.baidu.com/index.php?title=jspopular 2.获取密钥:http://lbsyun.baidu. ...

  2. Mixed Content: xxx This request has been blocked; the content must be served over HTTPS.

    在升级https的过程中,出现如下问题: Mixed Content: The page at 'https://www.xxx.com/denglu.html' was loaded over HT ...

  3. https下 http的会被阻塞 This request has been blocked; the content must be served over HTTPS.

    如何在HTTPS 网页中引入HTTP资源: Mixed Content? https://segmentfault.com/q/1010000005872734/a-1020000005874533 ...

  4. 【Https异常】This request has been blocked; the content must be served over HTTPS

    一.问题出现场景 项目从http升级到https后,jsp页面存在发送http请求的情况下就会出现该异常.因为HTTPS 是 HTTP over Secure Socket Layer,以安全为目标的 ...

  5. 在普通网页显示正常,加Https报This request has been blocked; the content must be served over HTTPS.,https网站加载http资源时,http资源被block

    解决办法 :在html头加<meta http-equiv="Content-Security-Policy" content="upgrade-insecure- ...

  6. This request has been blocked; the content must be served over HTTPS.处理方案

    在页面head标签中加入 <meta http-equiv="Content-Security-Policy" content="upgrade-insecure- ...

  7. Java Content Repository API 简介 转自(https://www.ibm.com/developerworks/cn/java/j-jcr/)

    Java Content Repository API 简介 1 如果曾经试过开发内容管理应用程序,那么您应当非常清楚在实现内容系统时所遇到的固有难题.这个领地有点支离破碎,许多供应商都有自己的私有仓 ...

  8. Mixed Content: The page at 'https://a.t.com/login' was loaded over HTTPS, but requested an insecure stylesheet 非全站https

    Mixed Content: The page at 'https://a.t.com/login' was loaded over HTTPS, but requested an insecure ...

  9. 让浏览器不再显示 https 页面中的 http 请求警报<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">

    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests" ...

随机推荐

  1. 嵌入式02 STM32 实验07 串口通信

    STM32串口通信(F1系列包含3个USART和2个UART) 一.单片机与PC机串行通信研究目的和意义: 单片机自诞生以来以其性能稳定,价格低廉.功能强大.在智能仪器.工业装备以及日用电子消费产品中 ...

  2. Golang_小程序学golang

    1 前置条件 Golang基本情况自行baidu/google 1.1 环境与工具 IDE:liteide (windows ).mingw-w64 (gcc) DB:SQL Server 2008 ...

  3. 如何在linux中重置Mysql访问密码

    目录 跳过密码认证 重启MySQL: 用sql来修改root的密码 去掉'跳过密码'代码 假设我们使用的是root账户. 跳过密码认证 重置密码的第一步就是跳过MySQL的密码认证过程,方法如下: # ...

  4. 2019 浪潮java面试笔试题 (含面试题解析)

      本人5年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.浪潮等公司offer,岗位是Java后端开发,因为发展原因最终选择去了浪潮,入职一年时间了,之前面试了很多家公 ...

  5. rename file

    https://askubuntu.com/questions/790633/the-o-parameter-in-aria2c-cant-rename-the-downloaded-file You ...

  6. Java8stream表达式

    // 输出:hello System.out.println(Optional.ofNullable(hello).orElse("hei")); // 输出:hei System ...

  7. 图片Image转换为base64编码的方法

    1.FileReader 通过XMLHttpRequest请求图片Blob数据格式,然后利用FileReader转换为dataURL function toDataURL(url, callback) ...

  8. canvas实现酷炫气泡效果

    canvas实现动画主要是靠设置定时器(setinterval())和定时清除画布里的元素实现,canvas动画上手很简单,今天可以自己动手来实现一个酷炫气泡效果. 气泡炸裂效果(类似水面波纹) 代码 ...

  9. sqlserver 保存 立方米(m³)

    转载来源:https://bbs.csdn.net/topics/370186797 解决方案:在前面加 N,如:N'm³' 案例: create table tbn(name nvarchar(10 ...

  10. SpringBoot整合定时任务和异步任务处理

    SpringBoot定时任务schedule讲解 简介:讲解什么是定时任务和常见定时任务区别 1.常见定时任务 Java自带的java.util.Timer类 timer:配置比较麻烦,时间延后问题, ...