CloudFront获得X-Cache:来自具有状态码200的云端的错误

时间:2017-08-17 04:17:47

标签: amazon-web-services amazon-s3 amazon-cloudfront

我尝试使用具有两个S3来源的CloudFront来托管我的网站example.comS3-main用于网站,S3-resources用于资源。

所以我将S3-main设为default(*)。并S3-resources使用路径模式resources/*

当我走https://example.com时,我在index.html下成功加载了S3-main 但是,当我尝试获取https://example.com/resorces/something.jpg时,我再次获得了https://example.com/index.html标题,如下所示:

http GET https://example.com/resources/something.jpg

HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: keep-alive
Content-Length: 1518
Content-Type: text/html
Date: Thu, 17 Aug 2017 03:29:52 GMT
ETag: "9776b731a6c42de14c929c10b4fec28c"
Last-Modified: Thu, 17 Aug 2017 01:56:41 GMT
Server: AmazonS3
Via: 1.1 xxxxxxx.cloudfront.net (CloudFront)
X-Amz-Cf-Id: 3OVCtUAk8mGzKt2OJD5gX9KRLHG3CBSHXf-xxxxxxxx==
X-Cache: Error from cloudfront

为什么我同时获得HTTP/1.1 200 OKX-Cache: Error from cloudfront? 为什么我按照预期得到index.html而不是something.jpg

注意

我可以通过S3-resources.s3.amazonaws.com

获取图片
http GET https://S3-resources.s3.amazonaws.com/resources/something.jpg

Accept-Ranges: bytes
Content-Length: 176182
Content-Type: image/jpeg
Date: Thu, 17 Aug 2017 04:11:55 GMT
ETag: "xxxxxxx84b05fb6564323c"
Last-Modified: Thu, 17 Aug 2017 02:59:12 GMT
Server: AmazonS3
x-amz-id-2: xxxx/xxxl+ijjM3YTxtQ4LpdHReEOhUvAz7uPFmVwzs8Foe4WOE=
x-amz-request-id: XXXX145CA3

+--------------------+
| NOTE: binary data  |
+--------------------+

1 个答案:

答案 0 :(得分:0)

检查您的分发设置...具体来说,错误页面选项卡。

如果您配置了自定义错误响应,则听起来您的配置不正确。发生错误时,可以替换内容重写HTTP状态代码,并且您报告的行为将与此类(错误)配置完全一致。

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages.html