12

I've set up an example static website on Amazon S3 and I added a custom folder to it with file inside: custom-folder/index.html, but I'm getting Access Denied error when trying to access url /custom-folder.

The index document is configured to be index.html, so S3 should serve index.html when I'm accessing /custom-folder url, but it doesn't work.

How can I fix this?

2
  • what URL are you using to access the bucket? is it similar to: http://examplebucket.s3-website-us-west-2.amazonaws.com/custom-folder/ Commented Dec 31, 2017 at 10:03
  • I use this URL: https://s3.amazonaws.com/aws-website-myexamplewebsite/custom-folder It's a default URL that amazon set up for me when I chose "example static website" Commented Dec 31, 2017 at 10:16

2 Answers 2

31

It seems you are using the wrong URL to access the bucket. For example, when you enable to static website hosting feature in S3 (us-west-2 in this example), you are given a URL with the following format:

Endpoint : http://bucket-name.s3-website-us-west-2.amazonaws.com

You can see your endpoint by going to S3 > Click on your bucket > Bucket Properties > Static website hosting > should reveal your endpoint.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Yes! It helped. Thank you a lot Eytan!
you saved my day
A little more explanation on this would be nice - the problem is that it's really easy to accidentally use the s3 REST API endpoint which will cause these access denied issues on static site sub pages (the REST s3 endpoint for a bucket is not meant to host a site). Additional reading: aws.amazon.com/premiumsupport/knowledge-center/… - You gave the correct solution, it's just nice to know more about the "why".
11

In case it helps anyone else, I was using a AWS Cloudfront Distribution on top of an S3 bucket.

The solution to the "Access Denied" issue for me was to perform the / to /index.html redirect in Cloudfront (rather than S3).

This is achieved by setting the "Default Root Object" to index.html on the AWS Cloudfront Distribution (and disabling "Static website hosting" entirely in S3).

4 Comments

Per usual - can't find this anywhere in the AWS docs and this is exactly what I needed - thanks!
Saved me! Thank you, I did not turn off the static hosting option and things are still working.
This worked for me and I didn't even disable Static Wwebsite Hosting on the S3 bucket.
This worked for me. I had to go to 'Cloudfront -> Distributions -. [distribution] -> Edit Origin -> Settings -> Origin Path' to edit it after creation.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.