A few months ago, I noticed I was approaching my bandwidth limits on my hosting account. Switching hosting providers is a pain, so I decided to move some high-bandwidth graphics to Amazon S3, where the bandwidth is cheap and unlimited. All was well until I realized that Google was returning search results pointing to my bucket on s3.amazonaws.com instead of carltonbale.com. Luckily, AmazonAWS has a work-around. You can use your own domain name in an Amazon S3 bucket. Here are the instructions on how to do it, from beginning to end.
Introductory Steps for new Amazon S3 Users:
- First of all, obviously, you need your own domain name and your own Amazon S3 account
- Secondly, you need a way to create/manage Amazon S3 buckets, so you'll need to install a client on your PC.
- I recommend using Bucket Explorer, which is a full-featured and easy-to-use client that runs on Windows and Linux; (a Mac version is in private beta and should be available Oct 2007). A free, less-featured alternative is the S3 Organizer add-on for the Mozilla Firefox web browser.
- Install your application of choice and either:
- Open Bucket Explorer -or-
- Open Firefox and go to Tools menu -> S3 organizer, and click the Manage Accounts button
- Enter your AmazonAWS Access Key and Secret Key
- These are available by going to http://aws.amazon.com, mousing-over the "Your Web Services Account" in the upper right-hand corner, and selecting "AWS Access Identifiers"
How to Alias your Subdomain to an Amazon S3 Bucket:
- Identify the exact domain name you want to forward to Amazon S3. S3 is not a web server, so I would not recommend forwarding your entire domain there, but rather a sub-domain. The sub-domain I'm going to use is the actual one I setup: s3.carltonbale.com
- Create a new "bucket" (a.k.a. folder) by clicking the "create folder/bucket" icon. Name the bucket exactly what your sub-domain name is.
- Example bucket name: s3.carltonbale.com
- Note: you must use a unique bucket name; you won't be able to create bucket if the name is already being used by someone else.
- Now comes the tricky part: modifying your DNS server settings. The procedures on how to do this vary by host and software system, but are the general steps:
- Logon to your web host control panel and select "Manage DNS Server Settings" or similar
- Create a new CNAME entry for your domain. For my example of s3.carltonbale.com, the entry was:
- Name: s3
- Type: CNAME
- Value: s3.amazonaws.com.
- (If you are an European users, use s3-external-3.amazonaws.com. instead)
- And yes, the dot at the end of "s3.amazonaws.com." is correct, at least for me. Look at your other entries to figure out what your should enter.
- Now comes the hardest part: waiting. It took about 2 hours for my subdomain to be recognized by AmazonAWS.
- Open the subdomain name in your browser. You should now be able to access your files through any of 3 urls:
- subdomain.domain.com (as long as the bucket name is the same as the full subdomain name, it is not necessary to specify the bucket name again at the end of the url)
- your_bucket_name.s3.amazonaws.com
- s3.amazonaws.com/your_bucket_name
Final Steps
- You'll need to set permissions on your bucket and the files within using your favorite bucket management tool. I recommend setting the bucket permission to "full control by owner" only and setting the permissions of the files within the bucket to "full control by owner, read access for everyone". This will prevent people from being able to browse/list the files in your bucket.
- If you don't want Google (or Google Images) to index the files in your subdomain, create a file named robots.txt containing the following and copy it into your bucket:
User-agent: *
Disallow: /
That's it, my start-to-finish guide on how to use your own domain name with Amazon S3. If I missed something or if something isn't clear, let me know in the comments and I'll fix it.


Great tutorial. Thanks!
The Amazon docs didn't go into detail so I was left wondering how to do it. This helped out a lot.
One thing: "s3.amaonaws.com.", it should be "s3.amazonaws.com." It almost tripped me up when I copied and pasted.
Glad you found it useful and thanks for catching the typo — it's fixed now!
Step 5.2 is incorrect. It's your_bucket_name.s3.amazonaws.com. Insert "s3.".
Thanks
Matthias
Matthias: Thanks for the correction; the post has been updated.
Thanks
Thank you very much for posting this article, it's a VERY important thing, and still after reading AWS articles & docs I had no clue whether it's possible or not.
I'm really excited about opportunities given by the S3, but it was quite upsetting to think that one couldn't use own dns there.
It's one thing if you start a project that uses Amazon's brand (by mentioning AWS in its description and URLs of the files) to gain some credibility – but for many serious projects that have their own brands etc it's better not to confuse users with links to Amazon.
And the the Google problem that's mentioned by you is a very important issue as well.
So, again, thank you very much for this article!
Thanks a million for writing this, it was exactly what I needed!
Thanks for publishing your tutorial. Worked just perfectly for the last few weeks.
Actually it still works but not for european buckets anymore.
If you access an EU bucket over the subdomain http://server.domain.com/ you'll instantly forwarded to:
http://server.domain.com.s3-external-3.amazonaws.com/
I noticed it today, so I guess Amazon changed some settings not more than a week ago.
I hope this is interesting for you and I'm looking forward for a reply
I have the same problem with a european bucket. Otherwise i guess it was a great guide
With European bucket, you should create the CNAME to "s3-external-3.amazonaws.com"
Meister: Thanks for the tip.
Thanks for the clear description on how to get this to work. It works great!
I've tried a while before I found out in your tutorial, that the bucket name must match the subdomain name – thx a lot for the description!
Thanks for the great description of exactly how to handle the CNAME. The Amazon doc is not too clear
I have this somewhat setup now with a couple of mp3 files and it goes right to the file and plays in Quicktime through FF. However, in IE, I get a Certificate Error.
AWS documentation mentions that https sites will give a certificate mismatch error.
Hey thanks for this, it's exactly what I was looking for and worked perfectly.
Hi
I tried doing this. Took a few attempts .. but got it working.. both this post and this post
http://www.wrichards.com/blog/2009/02/customize-your-amazon-s3-url/comment-page-1/#comment-135
were never clear on things.. let me give it a shot for people who get stuck..
You want your url like
http://superman.site.com/
Or
http://coolservername.site.com/
agreed?
Good..
1) Create your subdomain on your domain Cpanel folder.
For this example, I own test.com and the subdomain I created is batman.test.com
2) Open Cloud Explorer (free amazon s3 kit) and create your bucket.. this is the important part..
your bucket name must be your entire subdomain name
So create
"batman.test.com" as a bucket and not "batman"
NOW you can follow the rest of these tutorials
3) Your name should be a new CNAME entry for your domain. For my example of batman.test.com, the entry was:
* Name: batman
* Type: CNAME
* Value: s3.amazonaws.com.
* (If you are an European users, use s3-external-3.amazonaws.com. instead)
Thats it!
http://test.batman.com/loads/bucket/subfolders/logo.png
Enjoy!!
[...] Update: If you would like to use your own domain for accessing your files stored on S3 (e.g. cdn.mydomain.com instead of my-assets.s3.amazonaws.com), then you'll find this article useful: How to Alias a Domain Name or Sub Domain to Amazon S3 [...]
Great article, just what I was looking for. Thanks to Chris @ stillbreathing.co.uk for pointing it out.
One question, can you ftp and interact with a bucket and its content? I need to be able to upload and delete content oo the subdomain/bucket via scripts excuted from my main server.
Matt
S3 doesn't support FTP. You'll need a program that's implemented the S3 protocol and supports a command line interface, such as S3 Sync for Ruby.
Hi Carlton,
That was an amazing explanation. Thanks a lot.
A point regarding "final steps":
1) I recommend setting the bucket permission to "full control by owner" only and setting the permissions of the files within the bucket to "full control by owner, read access for everyone". This will prevent people from being able to browse/list the files in your bucket.
2) If you don't want Google (or Google Images) to index the files in your subdomain, create a file named robots.txt containing the following and copy it into your bucket:
Given the settings you did in #1 I think you can leave out #2. Reason being, If you set "full control by owner" ONLY for the bucket then googlebot will NOT be able to read the robots.txt that is placed in the bucket. Hence whether you have the robots.txt or not it won't make any difference.
Well, I take back what I said above because I am able to access the robots.txt even if my bucket is not set to read for all. This is out of my understanding. May be Carlton you can throw some light?
Now given this, I am just setting my robots.txt to be read by everyone while other files will only use time limited expiring URL's.
Just what I needed, thanks!
Your a lifesaver dude!