After I learned how to use
PHP to move files to S3. I was looking for a way to do this in a transparant way, so you'll still be able to use your own domain name when storing your files on S3.
Twitter uses S3 for storing its user avatars, try loading the
timeline and you'll see the amazonaws.com url coming up in your browser status bar. While this is just a small and visual annoyance, it becomes an issue when people start linking directly to your files stored on Amazon S3. The direct link to a file on S3 will look something like
http://aws.amazonaws.com/your_bucket_name/your_file_name . This is not exactly pretty and you're missing out on a lot of Google juice. In this post I'll show you how to avoid this in a few simple steps. Only thing you need is an S3 account and access to your DNS config file.
Step 1
Open your prefered S3 access tool (I use
S3Fox) and authorize it with your Amazon AWS account. You'll find all access information on the
AWS site, if you haven't created an secret access key make one now, but remember not to give it to anybody. These keys are all you need for accessing the data on S3.
Step 2
Once you're in you need to create a new bucket in which you want to store your data. And now comes the important stuff:
You will need to give this bucket the same name as you want to call your subdomain you choose for accessing the data. If you want to access your images using a subdomain like
images.yourdomain.com, you'll need to create a bucket with the name
images.yourdomain.com . This will only work if your bucket has the same name as your subdomain has.
Step 3
The last thing you'll need to do now, is forward your subdomain to the amazon servers. This can be done by making a CNAME record in your DNS configuration that will point to the amazon S3 servers. How to do this depends on your hosting company, some allow you to create such an entry yourself, for others you'll need to create a ticket. This is the entry you'll need to create:
images.yourdomain.com CNAME pointing to
aws.amazon.com. (the ending dot is mandatory). If you created a bucket that's located in Europe, you'll need to point the subdomain to
s3-external-3.amazonaws.com. instead. It will take a few hours before the subdomain will propagate, so have some patience
That's It !
Alright you're all set. You'll be able to access all your files on S3 using your own subdomain. A file with a name image.jpg can be accessed using following url
http://images.yourdomain.com/image.jpg .
39 Comments
I'm also using cloudberry explorer ... it's also a great freeware programme... A bit more advanced.
J
I'm also using cloudberry explorer ... it's also a great freeware programme... A bit more advanced.
But what do you guys mean with CNAME support?
J
I'm also using cloudberry explorer ... it's also a great freeware programme... A bit more advanced.
But what do you guys mean with CNAME support?
J
Dave
Dave
Dave
Rina
Rina
Thanks for the good post.
Thanks
The correct way of doing it is to point the CNAME directly to your bucket address, so for a subdomain like images.johnsmith.net, the CNAME would be images.johnsmith.net.s3.amazonaws.com. (with ending dot).
Dentists in Brighton
Leave a Comment