Search code examples
amazon-web-servicesamazon-s3dnsamazon-route53

AWS S3 Redirect for Route53 not working for HTTPS


I am attempting to use AWS S3 Static Website Redirect to allow redirects from an Apex domain (example.com) to the www.example.com domain.

I used the following guide https://medium.com/faun/redirect-naked-domain-to-www-with-https-on-aws-route-53-e620e4ce989d

In Route53, I have created an A record for the apex domain example.com

example.com    A    Simple   s3-website-eu-west-1.amazonaws.com.

The www.example.domain points to a cloudfront distribution which distributes my website. The cloudfront domain will redirect all HTTP traffic to HTTPS

www.example.com   A    Simple    *************.cloudfront.net.

In S3, I have created a bucket for example.com and set it up to redirect all requests [example.com s3 bucket redirect rules The bucket is public and empty

The resulting behavior works for HTTP but times out for HTTPS

http://example.com -> https://www.example.com
https://example.com -> ETIMEDOUT
http://www.example.com -> https://www.example.com
https://www.example.com -> https://www.example.com

How can I fix this setup so that https://example.com -> https://www.example.com


Solution

  • The issue is S3 static website hosting doesn't support HTTPS. [ref]

    So you need to add a CloudFront in front of example.com s3 bucket and configure proper DNS records pointing to it