2

Right now when I upload a file to my Amazon s3 buckert the url to the file looks like this:

https://s3.amazonaws.com/<MY BUCKET NAME>/filename.extension

I would like to use something like this:

cdn.mysite.com/filename.extension

How can this be done?

If I need to do this via a CNAME please explain how to do that in the terminal as I don't have cpanel or any other GUI control panel.

JakeRow123
  • 135
  • 1
  • 2
  • 4

2 Answers2

3

Yes, you can point a CNAME at your S3 bucket Firstly, you need to name the S3 bucket after the hostname you wish to use, e.g. cdn.mysite.com. Then add a CNAME record for that hostname pointing at the full S3 hostname, i.e. cdn.mysite.com.s3.amazonaws.com.

mgorven
  • 30,615
  • 7
  • 79
  • 122
1

Just to be friendly to the search engines, I thought I would add an updated 2013 perspective.

  1. It's not entirely fair to say that S3 is a CDN. In actuality, Amazon provides a service called CloudFront, which acts as a true "Content Delivery Network". They have roughly 60 edge servers globally that cache your bucketed S3 content. If you wish to use that service, you can provide several URLs to map into your cached content and they find your content with the extended paths. I.e.

Gross S3 URL: https://s3.amazonaws.com//filename.extension

New sexy URL: http://cdn.yoursite.com//filename.extension

You can use a variety of CNAMES (canonical names) to even further mask it and cache a full static site there (www.yoursite.com).

  1. If you're simply looking to send your traffic to a static hosted site (or content) on S3 without the CloudFront feature, you can do so but Amazon makes it much easier to do it through their Route 53 service.
  2. In S3, you'd need to create a bucket called yourdomain.com
  3. Create an alias DNS record in your new Route 53 hosted zone and point to that bucket
  4. Create a www.yourdomain.com BUCKET in S3 to REDIRECT traffic to your yourdomain.com bucket. In a way you're mimicking the activities of a true DNS record but you're taking that action within S3.

Good luck!

Eric Keyte
  • 121
  • 4