18

I have an S3 bucket. When accessing its root URL via https://s3.amazonaws.com/... it tells me Access denied.

This S3 bucket doesn't have any permission rules defined for Everyone.

However, accessing the same bucket via our CloudFront Domain Name a full ListBucketResult is being returned.

CloudFront is giving a full directory listing, which we want to prevent.

How can I disable that listing via CloudFront?

I tried invalidating all objects (*) in CloudFront, without effect.

3
  • Can you link to the Cloudfront distribution? I don't recall ever seeing a directory listing via Cloudfront--it's certainly not the default behavior.
    – jamieb
    Commented Jan 18, 2013 at 2:50
  • Sure, it's: audio.bitesizeirishgaelic.com (C Name domain) and d1c44h11n1ag93.cloudfront.net
    – eoinoc
    Commented Jan 18, 2013 at 8:15
  • Am also facing the exact same issue. Did you solve it by setting Default Root as mentioned in the best answer ? Commented Dec 23, 2016 at 9:28

2 Answers 2

17

Did you already get it? If not, you can try setting Default Root object for your cloudfront distribution.

2
  • Thanks that saved me too! My bucket had no permissions whatsoever but still public listing through cloudfront when no default root object set.
    – LMS5400
    Commented Mar 9, 2018 at 17:18
  • 1
    You can also set the Default Root Object to a file that doesn't exist (ex. doesntexist.jpeg) and it will display an error saying "Access Denied".
    – MartinG
    Commented Apr 26, 2020 at 15:59
3

setting Default Root should work. Another option is to just put any index.html file at your root. You could take a blank text file and rename it "index.html", or put some generic HTML message in the file too. Either way, a call to root of your cloudfront distribution will just default to that file instead of listing your directories / files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.