Setting up Cloudfront with a Custom Origin
Our CDN provider, SimpleCDN, looks to be going through some hard times (http://admin.simplecdn.com/), so we’ve had to move our content somewhere else. Immediately, I brought up a new EC2 instance and fired up Varnish to keep things running for now, but that’s hardly a CDN.
Since the content that gets served is very dynamic, we need a CDN that support origin-pull and is, more importantly, competitively priced. We don’t have the traffic to justify a $1k/month CDN bill. Recently, Cloudfront, Amazon’s CDN offering began supporting EC2 origins. Since we run all of our infrastructure on Amazon, this seemed like a great idea. Unfortunately, there is no way to set this up from the AWS Console, so I hacked up a quick script in boto, and thought it was worth sharing.
This uses the latest version of boto (available here). I pull the latest trunk, but you may be able to use one of the distribution versions. The script I used was:
from boto.cloudfront import CloudFrontConnection
from boto.cloudfront.origin import CustomOrigin
c = CloudFrontConnection()
origin = CustomOrigin("www.bigforge.com", origin_protocol_policy='http-only')
distro = c.create_distribution(origin=origin, enabled=True, cnames=['cdn.bigforge.com'], comment='BigForge CDN')
print distro.domain_nam
It should be obvious what you have to change, and what gets printed out should be put in as a CNAME in your DNS. Go to your AWS Console, and you’ll see the Cloudfront distro being deployed. It took a few minutes to change to the “deployed” state.
It’s too bad to see SimpleCDN go, but if you need a mirror bucket solution, this works.
Category: Uncategorized | Tags: cdn, cloudfront, simplecdn
December 12th, 2010 at 3:51 pm
↑ Back to top
I always enjoy learning what other people think about Amazon Web Services and how they use them. Check out my very own tool CloudBerry Explorer that helps manage S3 on Windows . It is freeware. http://s3.cloudberrylab.com/ Newer version also supports setting up custom CloudFront origins.