How to correctly set up Amazon Route 53, CloudFront with custom origin


I am currently using Amazon Route 53 for my DNS setup and a custom origin (web server outside of Amazon). I’d like to add CloudFront to the mix but I’m not too sure how to set it up?

I’ve seen Amazon’s guide on setting up S3 with Route 53 and CloudFront, but I can’t seem to locate any information on doing all this with a custom origin.

Should I be setting it up to work as follows?

  1. CloudFront pulls the data from the naked domain’s IP address
  2. The ‘www’ is just an alias of the CloudFront distribution

I originally planned to host my content on S3 but decided against it because I’d like more control over the hosting (for example, having the ability to use an .htaccess file and ban hacker IPs, etc).



OK so this is how I managed to solve it in the end:

Origin Server:

  • In cPanel (on my origin server) I created a sub-domain called
  • shares the same document root as
  • My .htaccess file redirects to

Amazon CloudFront:

  • The “Alternate Domain Names (CNAMEs)” is set to
  • The origin is set to

Amazon Route 53

  • The A record for is set to my origin server’s IP address
  • The A record for is set to an alias for the CloudFront distribution
  • is a CNAME for

Thanks to Matt Houser and Bruce P for their help, by the way. 🙂

Leave a Reply