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. Flutter 增加三方库卡在flutter package get 的解决办法

    修改 pubspec.yaml 文件增加第三方库之后,AndroidStudio 像往常一样提示 需要 package get. 然后一直卡在 Running "flutter packag ...

  2. Mybatis自动生成代码工具

    项目结构如下 一:在POM中添加mybatis-generator-maven-plugin 插件 <plugins> <plugin> <groupId>org. ...

  3. idea 添加 VUE 的语法

    1,首先我们先让 HTML 文件支持 VUE 的语法指令提示 2,File -> Setting -> Edit -> Inspections -> html 3.加入以下: ...

  4. 阿里巴巴 Java 开发手册 (七) 控制语句

    1. [强制]在一个 switch 块内,每个 case 要么通过 break/return 等来终止,要么注释说明程 序将继续执行到哪一个 case 为止:在一个 switch 块内,都必须包含一个 ...

  5. 3. ABP .NETCore 添加企业微信第三方登录

    1.企业微信登录步骤 1.获取企业微信Token 官方文档:https://work.weixin.qq.com/api/doc#90000/90135/91039 2.通过Token 与前端传的Co ...

  6. 【开发笔记】- Java写入、读取文本

    文本写入 public static void createFile(String input) throws IOException { //设置文件路径 String filePath = &qu ...

  7. 基于 k8s-搭建 Kubernetes 的 web 管理界面

    查看我们的k8s环境是否正常: 使用kubectl get nodes 获取我们的节点的信息: 到此说明我们的kubernetes环境是正常的,接下来就可以实验了 第一步在master上传所需的软件包 ...

  8. Radmin入侵

    Radmin (Remote Administrator)是一款屡获殊荣的远程控制软件,它将远程控制.外包服务组件.以及网络监控结合到一个系统里,提供目前为止最快速.强健而安全的工具包 生成被控端 点 ...

  9. 使用SAP Cloud Application Programming模型开发OData的一个实际例子

    刚刚过去的SAP TechEd上,SAP CTO Juergen Mueller向外界传递了一个重要的信息:身处云时代大环境下的SAP从业者,在SAP云平台上该如何选择适合自己的开发方式? Juerg ...

  10. centos7 上Docker安装与启动

    1.  docker  centos 文档地址 https://docs.docker.com/install/linux/docker-ce/centos/ 2. 安装环境说明: docker社区版 ...