1

I have a Web and I wanted to move its images to AWS S3. Say it's called mypage.com and I can access to an image like this:

https://mypage.com/pics/one.jpg

I created a bucket called static.mypage.com to put there all the images, so now I can access to the images like this:

https://static.mypage.com.s3.eu-west-1.amazonaws.com/pics/one.jpg

As it is a very long name, I want use a "shortener" using DNS.

So, I'd want to know how to set the CNAME in my DNS provider to make possible that if I go to...

https://static.mypage.com/pics/one.jpg

...I'd get the images from the bucket.

Thanks!

Brief: I just want to map every access to static.mypage.com to static.mypage.com.s3.eu-west-1.amazonaws.com

Ommadawn
  • 2,450
  • 3
  • 24
  • 48

2 Answers2

2

Assuming you own the domain name you can set a CNAME (or Alias record) for the domain as long as the bucket is named exactly what the hostname will be. However, this will not work for HTTPS as the certificate that is served is for the amazonaws.com domain.

If you want to access the domain as a HTTPS domain you should create a CloudFront distribution which uses your S3 bucket as an origin. You would set the alternative name as your chosen domain and then use the CNAME provided as your DNS value.

For more information take a look at the How do I use CloudFront to serve HTTPS requests for my Amazon S3 bucket? documentation.

Chris Williams
  • 32,215
  • 4
  • 30
  • 68
0

I have found an alternate solution that avoids DNS CNAME and CloudFront costs: make it all inside the NGINX server. It's a great solution, optimized with proxy cache.

Here's the solution: Nginx proxy Amazon S3 resources

Hope this helps as it helped me! :)

Ommadawn
  • 2,450
  • 3
  • 24
  • 48