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. 如何修改通过Anaconda安装的jupyter notebook的工作目录

    通过Anaconda安装jupyter notebook,对新手来说是一个非常明智的选择,可以避免很多不必要的麻烦! jupyter notbook默认情况下的工作目录是c:\user\...,接下来 ...

  2. day26——tyoe元类与object的联系、反射、函数与方法的区别、双下方法

    day26 type元类与object联系 type 获取对象从属于的类 python 中一切皆对象, 类在某种意义上也是一个对象,python中自己定义的类,以及大部分内置类,都是由type元类(构 ...

  3. todolist 包含本地存储知识

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. Python入门 常量 注释 基础数据类型 用户输入 流程控制

    Python入门 一.常量 在Python中,不像其他语言有绝对的常量,修改会报错,在Python中有个约定俗成的规定--常量就是将变量名大写. 尽量保持不更改的一种量 , 这个常量有是干什么的呢 其 ...

  5. Linux下的应用进程监控

    两个思路: 一.定时执行监控脚本 采用centos自带的crontab根据需要定时执行status.sh脚本 #!/bin/bash status=$(ps -aux | grep "rsy ...

  6. python 递归\for循环_斐波那契数列

    # 递归 def myAdd(a, b): c = a + b print(c) if c > 100: return return myAdd(a + 1, c) #最大递归深度是1000 m ...

  7. tf.reduce_max的运用

    a=np.array([[[[1],[2],[3]],[[4],[25],[6]]],[[[27],[8],[99]],[[10],[11],[12]]],[[[13],[14],[15]],[[16 ...

  8. aria2 adduri

    demo, ok import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handl ...

  9. html5的基本介绍

    前言 (1)什么是HTML? 指超文本标记语言(Hyper Text Markup Language); 是用来描述网页的一种语言: 不是编程语言,是一种标记语言: (更多详细内容,百度:https: ...

  10. java自定义注释及其信息提取

    转自:https://xuwenjin666.iteye.com/blog/1637247 1. 自定义注解 import java.lang.annotation.Retention; import ...