Tuesday, August 7, 2018

SSL setup with cloudfront for ec2 instance in AWS



Kindly follow the following steps to setup cloudfront for ec2 instance.

Prerequisite: We considered, You have already setup ec2 instance which serve your site on http://

  • Once login to aws. Go to Cloudfront distribution. click on "create distribution"
  • Press "Get Started" button under the Web section.
  • In "Origin Domain name" provide your ec2 public dns name over there it could be like "ec2-ip.us-east-2.compute.amazonaws.com" .
  • In "Origin Protocol Policy" keep selected "HTTP only".
  • In "Viewer protocol policy" select "Redirect HTTP to HTTPS"
  • In "Allowed HTTP Methods" select the required radio button, going to use in your site. 
  • In "Cached based on selected request headers" select "Whitelist" from drop down box.
          - Select atleast following "Whitelist headers"
    • Host
    • Origin
    • Referrer
    • Authorization
    • CloudFront-Forwarded-Proto
  • In "Forward Cookie" select "All" from drop down.
  • In "Query string forwarding and caching" select "All" from drop down.
  • In "Compress object Automatically" select "Yes"
  • In "Alternate Domain Names", Enter your domain name,
  • In "SSL Certificate", Select "Custom SSL certificate" Radio button, and from next drop down, select your site certificate which you have already create through ACM.
  • Press "Create Distribution" button. It will create your cloudfront distribution. It will give public cloudfront domain name like "xyz.cloudfront.net".
  • Use this cloudfront domain name as CNAME in your DNS.

No comments: