How to use your own domain with Amazon S3
Posted on September 2nd, 2009 in Tutorials | 7 Comments »
Level: Advanced
Today you are going to learn how to point your own domain or sub-domain to your Amazon S3 account. In this setup, for example, when user access http://media.your-domain.com/you-file.pdf they actually download the file from Amazon S3.
Managing your files in Amazon S3 account is not much different from using FTP and your web hosting. Every time you upload file to Amazon S3 it gets two URLs that can be used to get access to it.
First URL looks like:
http://s3.amazonaws.com/bucket_name/file_name.ext
Second URL looks like:
http://bucket_name.s3.amazonaws.com/file_name.ext
As you can see, in a first example bucket name is used as part of file path and in a second example it is a part of domain name. These two URL are identical and point to the same file.
To configure your own sub-domain to point to Amazon S3, first you need to create a bucket with a name of your sub-domain. Use one of the tools from my previous blog post to do it. For example, for media.your-domain.com sub-domain you need to create a bucket with exactly the same name media.your-domain.com.
Next, using your DNS hosting provider for your-domain.com, create a CNAME record media that points to media.your-domain.com.s3.amazonaws.com.
The way you create a CNAME record depends on your domain DNS hosting provider. This example will show you how to do it with GoDaddy’s Total DNS Control.
Start with logging in to GoDaddy Control Panel. Select Domain Manager.
In the Domain Manager click the domain you’d like to use.
Scroll down until you see Total DNS menu. Go to Total DNS Control.
Click Add New CNAME Record button.
In the pop-up window enter a first part of a sub-domain name as an Alias Name. For media.your-domain.com it will be media.
After you finish, all files in media.your-domain.com bucket will be accessible using http://media.your-domain.com/file_name.ext URLs.
You can create separate Amazon S3 sub-domains for you web site images or large video files.
Please leave you comments and let me know what you think.
If you enjoyed this post, get free updates by email or RSS




