1

I am bit confused with setting up Amazon Cloudfront and S3 bucket.

I've got my bucket setup and using the wordpress WP Offload S3 plugin to store any images in this bucket. When checking the image URL in the media manager, all seems to work fine and URL points to the bucket.

I've got the Cloudfront distribution set up, pointed at the S3 bucket as an origin.

But now when I access my Cloudfront distribution URL directly, (xxxxxxxxx.cloudfront.net), I just get the page with the following:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
   <Code>AccessDenied</Code>
   <Message>Access Denied</Message>
   <RequestId>XXXXXXXXXXXXXX</RequestId>
   <HostId>
     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
   </HostId>
</Error>  

If I access my Cloudfront distribution URL, I should be seeing my cached version of the website, correct?

Instead is seems that my current distribution is only working for the S3 bucket with images, but not on the actual website.

So do I need to set up an additional origin for the same distribution??

To have one origin for the actual domain example.com and the other origin for the S3 bucket?

0

Q: If I access my Cloudfront distribution URL, I should be seeing my cached version of the website, correct?

A: No.

You've configured CloudFront to cache S3. S3 contains your images, not your website. If you want to see your website you need to request from your web server.

If you want CloudFront to cache your whole website you need to set it up with the web server as the source for the distribution. You can still use the S3 offload but the source will be the web server not S3. You will only have one CloudFront distribution.

  • "If you want CloudFront to cache your whole website you need to set it up with the web server as the source for the distribution." Not necessarily "the source," but rather "a source" (origin). CloudFront supports multiple origin servers, choosing which one serves each request based on the path patterns declared in the cache behaviors... so direct to web server and direct to S3 is supported, by configuring multiple origins on a single distribution, and then the appropriate path patterns to match. – Michael - sqlbot Nov 26 '16 at 4:52
  • That's true, but I was keeping it simple and recommending a solution. No point having two origins. – Tim Nov 26 '16 at 5:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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