Cloudfront 在提供 HTTPS 内容时不一致

Cloudfront is inconsistent in serving HTTPS content

我正在尝试更新我的博客 (jacopretorius.net) to use HTTPS. Instead of just trying this on the live version I have created a staging version to test this - staging.jacopretorius.net

我的堆栈是这样的:

我正在使用 s3_website gem 将生成的 Jekyll 内容部署到 S3 存储桶。此 gem 还会更新关联的 Cloudfront 分布。我将 Cloudfront 分发配置为使用我的证书,并将暂存 URL 作为 CName 添加到分发中。最后,我从 Route 53 添加了 2 个别名以指向分发,一个用于 IPv4,一个用于 IPv5。

一切似乎都按预期工作,除了一些我不明白的奇怪行为。所有页面似乎都是通过 HTTPS 提供的,但 https://staging.jacopretorius.net/archive/. I thought this might be because the URL doesn't have an extension, but https://staging.jacopretorius.net/about/ 除外。这种情况在 Chrome 和 Safari 中一直存在。

当我使用 curl 转储 headers 时,headers 似乎表明 URL(/about/ 一个)始终是 Cloudfront 未命中。

curl -s -D - https://staging.jacopretorius.net/archive/ -o /dev/null
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 63941
Connection: keep-alive
Date: Sun, 22 Oct 2017 20:11:29 GMT
Last-Modified: Sun, 22 Oct 2017 19:25:42 GMT
ETag: "289e13a6c58bd46dfa55d22cd5e0d1a6"
Server: AmazonS3
Age: 51
X-Cache: Hit from cloudfront
Via: 1.1 0a955f76d9c9f3e49899a6eb7a411ec5.cloudfront.net (CloudFront)
X-Amz-Cf-Id: avt5CRfDiCwEU7TlhvUoCQKsR_jGB_2M_w5zy5mmDoFhogtS4doaQA==
curl -s -D - https://staging.jacopretorius.net/about/ -o /dev/null
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 3757
Connection: keep-alive
Date: Sun, 22 Oct 2017 20:12:24 GMT
Last-Modified: Sun, 22 Oct 2017 19:25:42 GMT
ETag: "fa3a2f263be864012dc5a792d651a46c"
Server: AmazonS3
X-Cache: Miss from cloudfront
Via: 1.1 fc8718fc654846d5ff65e1100874c1fc.cloudfront.net (CloudFront)
X-Amz-Cf-Id: btONKzglg2FkPo9ycWiqQz-aBQ85sugrwTES14TfmedmBQNPPim_Jg==

Cloudfront documentation好像是说这种URL没有问题,只是说你要保持一致(我就是)。

我真的被这个难住了。我在这里唯一的想法是,Cloudfront 以某种方式缓存了 /archive/ 响应,并且它第一次尝试检索该资产时没有得到预期的响应,但这并没有完全加起来,因为内容在那里,它是只是不是 HTTPS。

https://staging.jacopretorius.net/archive/ 页面在我加载时被认为是安全的。是什么让您说它没有完全安全地提供服务?如果您输入 https:// 并看到页面内容,则该页面是通过 HTTPS 提供的,但如果您没有看到绿色锁图标,则浏览器认为该页面不完全安全。您需要单击 Chrome 浏览器地址栏中的小 (i) 图标,看看实际问题是什么。如果该页面上的 SSL 证书有问题,浏览器根本不会显示任何页面内容。

我在 Chrome 中看到一条消息,指出并非页面上的所有内容都是安全的。我认为那是因为页面上的搜索表单有一个 http://www.google.com/search 目标。尝试将其更改为 https://www.google.com/search(并在进行更改后清除 /archive/ 的 CloudFront 缓存)。