我試圖使用具有兩個S3來源的CloudFront託管我的站點example.com
。 S3-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 OK
和X-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 |
+--------------------+
謝謝你的幫忙。我發現原因是我已經將錯誤頁面設置爲index.html。同時,miss將'resources/*'配置爲'S3-main'。所以當'http GET https:// example.com/resources/something.jpg'時,它應該會遇到一個404錯誤,但是被index.html返回值重寫爲200。 – kehao