ssl - 使用具有自定义域的 github 页面时出现混合内容错误

标签 ssl https github-pages cloudflare mixed-content

我在 Cloudflare 中使用自定义域 ( https://thebotspeaks.com) 托管我的 git-hub 页面网站 (peps09791.github.io)。 为了启用 HTTPS,我做了以下配置:

  1. 在我的 _config.yaml 文件中 我已经相应地设置了 URL 键

    网址:“https://peps0791.github.io”

  2. 在我的 cloudFlare 仪表板中,我启用了 HTTPS 重写选项以防止混合内容错误。

  3. 我还从 CloudFlare 启用了 Flexible SSL。

我没有启用默认的 HTTPS 重定向,因为该网站突破了 HTTPS。在 HTTP 上,它工作正常。

现在,当我尝试使用 HTTPS 访问我的网站时,出现混合内容错误:

Mixed Content: The page at 'https://thebotspeaks.com/' was loaded over HTTPS, but requested an insecure image 'http://thebotspeaks.com/assets/images/bio-photo.jpg'. This content should also be served over HTTPS.

09:54:45.323 (index):1 Mixed Content: The page at 'https://thebotspeaks.com/' was loaded over HTTPS, but requested an insecure stylesheet 'http://thebotspeaks.com/assets/css/main.css'. This request has been blocked; the content must be served over HTTPS.

09:54:45.785 (index):1 Mixed Content: The page at 'https://thebotspeaks.com/' was loaded over HTTPS, but requested an insecure script 'http://thebotspeaks.com/assets/js/main.min.js'. This request has been blocked; the content must be served over HTTPS.

从控制台,我可以看到:

<script src="https://peps0791.github.io/assets/js/main.min.js"></script>

<link rel="stylesheet" href="https://peps0791.github.io/assets/css/main.css">

我该如何解决这个问题?

最佳答案

这里的问题是您的 Assets (即您的 CSS 或 JavaScript)正在重定向到您网站的 HTTP 版本。这是因为您的 Assets 直接引用您的 GitHub 站点,而不是启用 Cloudflare 的域。

例如;您的 HTML 在 https://peps0791.github.io/assets/css/main.css 而不是 https://thebotspeaks.com/assets/css/main 引用您的 CSS 文件。 CSS

为了解决这个问题,您似乎需要更新 _config.yaml 文件以具有以下 URL key :

url: "https://thebotspeaks.com"

有关解决各种混合内容问题的更多一般建议可以在 Cloudflare 知识库的以下文章中找到:How do I fix the SSL Mixed Content Error Message?

关于ssl - 使用具有自定义域的 github 页面时出现混合内容错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46672558/

相关文章:

java - 如何按需启用 javax.net.debug

python-3.x - Selenium webdriver.Remote 在 Linux 上出现 SSL 错误,在 macOS 上工作

python - 使用 HTTPS 提供安全的 Django 页面

asp.net - IIS8 - 在同一台服务器上托管 SSL 和非 SSL 站点

重定向 GitHub Pages 上的多个网页

jekyll - 管理文件夹中的 Jekyll 页面(在 github-pages 上)

github-pages - 即使准备好发布,Github 页面也不会发布网站

c# - SignalR - 无法为 SSL/TLS 安全通道建立信任关系

c++ - 如何通过 QSslSocket 分别发送两个字节?

security - JWT RS256:通过https获取公共(public) key 是否安全?