Alain Fontaine’s Jabberbox

Amazon CloudFront – easy CDN for the masses

by on Nov.13, 2010, under Technology


Amazon CloudFront is a relatively new product offering in the range of the AWS products. In a simple definition, you could say that CloudFront allows you to easily setup and use Amazon’s infrastructure to distribute your content (web or streaming) globally, by leveraging Amazon’s edge servers in the US, Europe, and Asia. You can just call it a CDN – Content Delivery Network, although that definition applies to services that often provide very distinct additional services, depending on the provider.

My today’s Saturday morning IT exercise was to quickly dive into the CloudFront universe and give it a spin on one of our lab websites – , which is a gift-list creating platform without any real commercial objective.

Read on to find out how easy it was to setup CloudFront on WishList !

I have some personal experience with CDN services from my job with atHome Group, where we now use Akamai technology as our CDN provider on our websites,, and We mainly use the CDN for static content, i.e. property photos, and JavaScript (.js) and stylesheet (.css) files, and we’ve had a very good experience with it so far. Content delivery is very fast in all countries we serve, and the origin servers are offloaded quite significantly. The apparent problem with services like Akamai is that they’re quite cumbersome and expensive to use for small scale projects that could benefit from a CDN other than to keep up with extreme traffic requirements (for instance, just to offload your origin servers from serving static content). CloudFront seems to be a solution for this. But let’s get into it right away.

The exercise

My exercise is quite simple : have all images (design elements and gift photos) on served globally via CloudFront instead of serving them locally. In other words, whenever a page call requires a picture to be displayed, I don’t want my own webserver serve that content, but I want CloudFront to do so.

It turned out that this was going to be a very easy task in fact! Let me give you a quick run-down of the involved steps.

  1. You need a valid AWS CloudFront account to get started, of course. You can sign-up using your credit card on the AWS website.
  2. You then need to setup a CloudFront distribution. A distribution is basically the definition of a CDN service, allowing you to specify your content origin (where your original content actually lives), plus a set of options related to it (is it web/http content, or streaming content? are there particular privacy settings to be applied? do you use http or https? etc.) Amazon says : A distribution specifies the location of the original version of your objects. A distribution has a unique domain name (e.g. that you can use to reference your objects through the network of edge locations. If you wish, you can also map your own domain name (e.g. to your distribution. You can create distributions to either download your content using the HTTP or HTTPS protocols, or stream your content using the RTMP protocol.
  3. Optionally, and that’s what I did, you configure a CNAME on your domain to point to the newly created CloudFront name – it makes things look sexier, if nothing else. In my case, this is, although it would have been smarter to create the CNAME on a cookie-less domain.


    nslookup output for my newly created CNAME

  4. Once your distribution is setup and configured, you need to configure your website’s code so that images are served through CloudFront instead of being served locally. If your code permits, it’s generally just a configuration setting that you change accordingly. On, it was as easy as changing one configuration setting as seen below.

    Editing the application source code

    As you can see here, we use a constant that defines the URL to be used in the <img /> tag of gift photos, and I’ve just told it to use the new CNAME (pointing to my freshly created CloudFront distribution) of my CDN. The result is now that the HTML code produced by our application contains this kind of <img /> tags :


  5. Done ! Yes, that’s it. Of course, I didn’t go into all of the details here, but these four steps are what it takes, in my case, to “CDNize” the website.


The only real challenge I encountered was to actually create a CloudFront Distribution that would use a custom origin. Distributions are designed to use Amazon S3 storage as their origin by default, but Amazon recently added the option to use your own servers as the origin for your CloudFront Distribution, making it unnecessary to first deploy (and later on sync and manage) your content to an S3 bucket. Unfortunately, the AWS Management Console, while allowing you to create CloudFront Distributions, does not yet allow you to specify your own origin server. You can currently only do that using the AWS CloudFront API.

Fortunately, there is a number of very nice graphical tools that allow you to leverage this API very conveniently. I chose to use the excellent CloudBerry Explorer for Amazon S3 to create my Distribution using a custom origin server.


Once your Distribution is setup, it will show up in the AWS Management Console and you can continue managing it from there, if you want, or you use the PRO version of CloudBerry Explorer which allows you to so, too.


The CloudFront service is ridiculously cheap.


In Europe, the most expensive price is 0.150 USD per transferred GB, with prices decreasing as your needs grow. This is especially true if you want to use CloudFront to reduce the load on your webservers that might struggle keeping up with the sheer number of requests caused by calling static content. That’s one of the big winners I see with this service – a very cheap and quick way to give your website or web application a good performance boost without the need of adding hardware or applying otherwise complicated and time consuming optimization measures.

:, , , , ,
  • cloudberryman

    Thank you so much for featuring CloudBerry Explorer on your blog.

  • nottinhill

    I enjoyed reading your blog entry. Any ideas which MacOSX tool would allow me to set my own origin server?

    Edit: I booted Windows and did it with Cloudberry. I did -not- manage to setup a custom origin with Transmit nor Cyberduck nor S3 Hub.

  • Greg

    Hello Alain, thanks for your post – this is exactly what I am working on at the moment except I am having a bit of trouble finding out exactly what to do when setting up the origin server distribution.

    I am on Windows and have looked at CloudBerry (you need the PRO account to use the CloudFront Feature), Bucket Explorer (keeps on erroring when installing), CloudBuddy (errored when downloading) and CyberDuck (the Windows version doesn’t seem to support origin server/CloudFront).

    What are the steps that you took using the API? Or can you suggest another method? I don’t currently have access to the management console but need to know exactly what is involved before I proceed.

    Thanks in advance!


    • Anonymous


      Thanks for your comment. I bought a licence of CloudBerry explorer to manage my custom origins; it’s be far the easiest way I found. I don’t think the AWS console lets you setup custom origins yet, so you have to use the API; or CloudBerry, which does so as well, but with a nice interface :)

      If you’re going to use CloudFront and custom origins on a regular basis or for pro needs, just spend the few bucks; it’ll save you much time and hassle.


      • Greg

        Thanks for your reply Alain!

        But that is exactly the problem, I only need to do it once so its not worth paying the money for CloudBerry.

        Is there another way I can do it just the once for free?

        • Anonymous

          Hi Greg,

          My (life and work) experience tells me that there’s only one thing you only do once: you get married in church just once :-) .

          Seriously though, I don’t know how to define the custom origin without a tool; I must admit I haven’t searched for alternatives either since I bought myself a licence of CloudBerry Pro; I use the tool also to manage by various S3 buckets etc, so all in all it’s pretty useful.


          • Greg

            Ok, thanks Alain! I will keep searching and let you know if I find something useful.



          • Alain Fontaine


            Just got this from Amazon :

            Dear Amazon CloudFront Customer,

            We are excited to announce that we have enhanced the CloudFront Management Console with several features that were previously only available via our API. You can now configure a custom origin for a CloudFront distribution, make a distribution accessible solely via HTTPS, and set a default root object using the CloudFront Management Console. Detailed documentation on Management Console support for these features is available in the Amazon CloudFront Developer Guide.

            In addition, you can continue to use the CloudFront Management Console to manage your download and streaming distributions, use your own domain name as a CNAME to the CloudFront domain name, and enable access logs by specifying the Amazon S3 bucket of your choice. The CloudFront Management Console also honors the AWS Identity and Access Management (IAM) policies you may set to limit actions that Users can take on your CloudFront distributions. There is no additional charge for using the Management Console.

            Learn more about Amazon CloudFront features that allow you to do even more with CloudFront such as: live HTTP streaming, custom origins, object invalidation, default root object, detailed log files, private content, video and audio streaming, and HTTPS.

  • helmet chennai

    Good article and very valuable information. Keep it up!

  • Domain Registration

    These information helps me consider some useful things, keep up the good work.

  • gaurav chopra

    thanks for putting this article – really you put some great information on your blog. i will love to refer this to my friends irctc pnr status

  • self drive cars chennai

    Good article and very valuable information. Keep it up!

  • Cheap wedding dresses

    Thanks for your article,like your blog very much,well done.

  • Domain registration

    Great information thanks to sharing the wonderful articles 

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...