6

I'm hosting a Jekyll blog on S3 and CloudFront. Setting the default document on S3 works fine and all sub folders natively go to index.html.

On my CloudFront distribution, I have set the Default Root Object to index.html, but sub directories do not get this - instead I get the following error

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>about</Key>
<RequestId>F8324894C093EB53</RequestId>
<HostId>
Girhbo7YLEl9sxPS3KjvhbkpL32qNsYgiVLElAhPOvqrekfqfpJ/2AAYRg4rNJ+t4Imc86cjiw4=
</HostId>
</Error>

If i browse manually to domain/subdir/index.html it works fine.

Any ideas?

Luke Griffith
  • 63
  • 1
  • 4

1 Answers1

8

When using an S3 bucket with the web site hosting feature (which enables index documents) you don't want to use the REST endpoint of the bucket, which is what CloudFront will offer you in the console. You need to type in the web site endpoint, instead.

On the Create Distribution page, for Origin Settings, type the Amazon S3 static website hosting endpoint for your bucket in the Origin Domain Name box, for example: example.com.s3-website-us-east-1.amazonaws.com.

Important

Do not select the name of your bucket from the list, such as example.com.s3.amazonaws.com.

http://docs.aws.amazon.com/gettingstarted/latest/swh/getting-started-create-cfdist.html

You can also turn off the default root object configuration in CloudFront. That isn't needed for this setup.

Remember that you may cached error responses for a few minutes after the change propagates. Check the X-Cache and Age response headers to determine if you are seeing a cached response and how long ago the response was cached.

Michael - sqlbot
  • 21,988
  • 1
  • 57
  • 81