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!
Best Answer
In the past S3 supported FQDN bucket names - i.e. exactly what you needed. Where FQDN = Fully Qualified Domain Name, i.e. full host name like static.mypage.com. The problem is that this only works with HTTP and not with HTTPS because there is no way to make S3 use a SSL certificate with your bucket name / host name (static.mypage.com).
You can still do it if you're happy with HTTP-only traffic. Simply create a
static.mypage.com
CNAME at your registrar pointing tos3.eu-west-1.amazonaws.com
. S3 will recognise theHost:
header in the request and look into the right S3 bucket. Provided that the objects in the bucket are publicly accessible the URL http://static.mypage.com/pics/one.jpg should work just fine.However as soon as you access the same over HTTPS you will get a SSL Certificate Validation error because the hostname in the S3 certificate *.s3.eu-west-1.amazonaws.com won't match the expected static.mysite.com.
The solution is CloudFront which can sit in front of your S3 and handle the right SSL certificate for it:
Also have a look at Routing traffic to a website that is hosted in an Amazon S3 bucket.
Hope that helps :)