Cloudfront responded AccessDenied or NoSuchKey

0

For example, 1. https://d2u87yfqb01lll.cloudfront.net/test/ Returns AccessDenied error.

But the URL below is done responding successfully. https://d2u87yfqb01lll.cloudfront.net/test/index.html

https://d12dcz4jiki7qg.cloudfront.net/%e2%80%aabitcoin-straight-up-gave-me-the-middle-finger-today%e2%80%ac-reddit-bitcoin/ Returns NoSuchKey error.

But the URL below is done responding successfully. https://d12dcz4jiki7qg.cloudfront.net/%e2%80%aabitcoin-straight-up-gave-me-the-middle-finger-today%e2%80%ac-reddit-bitcoin/index.html

Both are setup correctly. I enbaled S3 hosting for the contents(index.html as the default page is setup). Made the bucket and all the objects under the bucket public access. ACL are both enabled. Cloudfront has default root object.

Please let me know which steps I might have missed. Many thanks.

已提問 2 年前檢視次數 916 次
2 個答案
1

CloudFront allows you to specify a default root object like index.html, but it only works on the root of the website (such as http://www.example.com > http://www.example.com/index.html). It does not work on any subdirectory (such as http://www.example.com/about/). When you make a request like this, CloudFront makes a GetObject request to S3 for an object that doesn't exist.

You can implement default document functionality for subdirectories via Lambda@Edge. Please refer to this blog post: https://aws.amazon.com/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/ for details.

AWS
專家
Paul_L
已回答 2 年前
  • Thank you for your answer. But it worked in my other distributions. I can access any subfolders by using /anypath/, no need to specify which root object I need to get. So, I think this is not caused by my setting.

0

Now, I still can't access https://d2u87yfqb01lll.cloudfront.net/test/ But the situation changed. It popped up a download dialog with 0 byte. Seems some tech guys are fixing this bug.

https://d12dcz4jiki7qg.cloudfront.net/%e2%80%aabitcoin-straight-up-gave-me-the-middle-finger-today%e2%80%ac-reddit-bitcoin/ Still returns NoSuchKey error.

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南