Avoid CloudFront Circular References

When migrating to CloudFront don’t introduce circular references. This should be obvious, but sometimes in the heat of battle, details get overlooked and everything comes crashing to the ground.

tl;dr: If CloudFront is going to front your www.example.com domain, you cannot point your distribution origin to www.example.com. You might irrationally be tempted to do this because you have an existing shared provider where things are already running well and successfully, and you don’t want to be bothered using S3 instead.

If your public domain — specified in your DNS CNAME record — is www.example.com, and CloudFront is trying to pull from the origin www.example.com, you will have problems.

You could solve this by using another domain on your shared host, e.g., origin.example.com, but in most cPanel hosting environments this means setting up a new subdomain and assigning a new root directory. And of course, anyone could still access your origin site using the origin.example.com domain directly.

In the end, I simply put everything into S3 and used that as CloudFront's origin.

However, that wasn’t as painless as I thought, either, due to both lack of foresight and having to decided how to deal with my “cool URLs”.

comments powered by Disqus