HOW TO CONFIG REDIRECT ROOT/NAKED ROUTE53 DOMAIN HTTP TO WWW HTTPS Using S3 and CloudFront with Route53

STEPs

  • S3 static website hosting bucket same domain name with direct mode
  • Cloudfront using Origin domain of S3 website endpoint (NOT bucket name) + custom domain + custom SSL (via ACM)
  • Route53 -> alias to CloudFront (us-east-1 only)

DETAILs

S3:

  • New empty bucket using bucket name must be equal domain name
  • Bucket properties -> Static website hosting -> Enabled -> Redirect requests for an object -> your domain name, protocol is https

CloudFront:

  • CORRECT (IMPORTANT) Origin domain: dont use the auto filled domain -> Need to type yourself to: domain.com.s3-website-ap-southeast-1.amazonaws.com (NOT domain.com.s3.ap-southeast-1.amazonaws.com)
  • Set custom ssl using ACM (AWS Certificate Manager): Select US East (N. Virginia) region -> request domain -> add CNAME ssl to route53 -> Waiting for issuing
  • Set alternative domain to root domain + Custom ssl using cert above
  • Origin Shield => No
  • Cache key and origin requests -> Legacy cache settings -> All Headers; All Query strings; All Cookies

Route53:

  • New record with A + Alias to CloudFront distribution -> Select CloudFront above

Leave a Reply

Your email address will not be published.Required fields are marked *