2017-08-17 254 views
0

我試圖使用具有兩個S3來源的CloudFront託管我的站點example.comS3-main爲該網站,S3-resources爲資源。CloudFront從狀態碼200的Cloudfront中得到X-Cache:錯誤

所以我設置S3-main作爲default(*)。和S3-resources與路徑模式resources/*

當我去https://example.com我成功加載下S3-main
index.html但是,當我試圖讓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 | 
+--------------------+ 

回答

0

檢查分佈設置...具體而言,錯誤頁面標籤。

如果您配置了自定義錯誤響應,則聽起來您已錯誤地配置它們。當發生錯誤時,可以用內容替代HTTP狀態代碼,並且報告的行爲與這種(錯誤)配置完全一致。

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

+0

謝謝你的幫忙。我發現原因是我已經將錯誤頁面設置爲index.html。同時,miss將'resources/*'配置爲'S3-main'。所以當'http GET https:// example.com/resources/something.jpg'時,它應該會遇到一個404錯誤,但是被index.html返回值重寫爲200。 – kehao