【问题标题】:Why is mixed content on google chrome not working为什么谷歌浏览器上的混合内容不起作用
【发布时间】:2021-05-25 00:07:43
【问题描述】:

我有一个通过安全连接 (https://) 加载的网站。我有一个指向http:// 的链接,可以下载文件。我想在这里使用混合内容解决方案(我知道我应该做 https:// 但现在我想使用http://)。所以为了修复我在头部添加了<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">。出于某种原因,我仍然在谷歌浏览器中收到混合内容错误。我目前的 chrome 版本是 88。

【问题讨论】:

    标签: html google-chrome http https mixed-content


    【解决方案1】:

    来自MDN

    HTTP Content-Security-Policy (CSP) upgrade-insecure-requests 指令指示用户代理将网站的所有不安全 URL(通过 HTTP 提供的)视为已被安全 URL(通过 HTTPS 提供)替换。

    该指令允许混合内容。它只是将所有http: 链接视为https: 链接(例如,如果单击指向http://google.com/ 的链接,浏览器将导航到https://google.com/)。允许混合内容的唯一方法(AFAIK)是:

    • 通过纯 HTTP 提供您的内容,或
    • 在网站设置中手动允许混合内容。

    【讨论】:

    • 那么,最好的选择是在 href 中使用 https:// 呢?意思是避免混合内容。
    • 如果您说的是正确的,那么为什么我会收到此错误? Mixed Content: The site at https://xxxx was loaded over a secure connection, but the file at http://xxx was redirected through an insecure connection. This file should be served over HTTPS. This download has been blocked. See https://blog.chromium.org/2020/02/protecting-users-from-insecure.html for more details.我不应该得到像Mixed Content: The site at https://xxxx was loaded over a secure connection, but the file at https://xxx was NOT available or something.这样的错误
    • 可能是因为浏览器尝试连接https://xxx但没有成功,所以改为连接http://xxx
    猜你喜欢
    • 2013-06-16
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    • 2018-12-07
    • 2015-06-16
    • 1970-01-01
    • 2010-11-08
    • 2012-12-27
    相关资源
    最近更新 更多