How to use CloudFront with ELB for http to https redirection

10,526

I got the solution after 10 days after a lots of R&D.

Http to https redirection using CloudFront

Follow below steps:

  1. Login into your aws console and search CloudFront

  2. Go to CloudFront: Create Distribution(please select Web distribution)

  3. Under Origin Settings : Select the Origin Domain Name (you can assign the IP is instance/You can opt the ELB/You can select the S3 bucket)
  4. Under Default Cache Behavior Settings : Select Viewer Protocol Policy: Redirect HTTP to HTTPS
  5. Under Object Caching: opt customize (Remain default setting in Minimum TTL , Maximum TTL and Default TTL)
  6. Forward Cookies : All
  7. Query String Forwarding and Caching : All
  8. Distribution Settings : Select Price Class: (Use All Edge Locations (Best Performance)).
  9. Alternate Domain Names (CNAMEs)s: add all domain names that you want to be directed at this Distribution
  10. SSL Certificate : Under SSL you can opt defaut or your custom certificate that depends upon your requirement.(here I am opting custom certificate.)

Note : For Custom SSL Certificate (certificate should be in us-east-1 region).

Final Step:

  1. Once the Distribution has been created (can took 15 to 20 minutes)
  2. Update your DNS CNAME to point to the ___.cloudfront.net address under Route 53.

Still you getting problem please let me know

Share:
10,526
Anoop Kumar
Author by

Anoop Kumar

I am an enthusiastic software engineer and machine learning researcher. My experiences range across a number of fields and technologies, but my primary focuses are in deep learning,Django and Python.

Updated on June 27, 2022

Comments

  • Anoop Kumar
    Anoop Kumar almost 2 years

    I have implemented AWS ELB for SSL. It's working fine with my domain. I want to redirect http to https. So I used the CloudFront for it. But after implementing the cloudfront, I didn't get success.

    For implementing the Cloudfront, I am using the default SSL because there is no certificate in region=us-east-1. I have updated the CNames in Route53.

    For generating the certificate under ELB I have opted global.

    Any suggestion?

  • Omkar Jadhav
    Omkar Jadhav over 5 years
    Hey I have used Elastic Beanstalk and currently the CNAME is pointing to the EBS ... you said point that to cloudfront in step 12. But then for Origin Settings ( 3rd point ) I still select the Elastic Load Balancer ?
  • Anoop Kumar
    Anoop Kumar over 5 years
    If you are using Route 53 for redirection then here we have 2 options to redirect the traffic to https 1. Under CNAME in Hosted Zone you have to mentioned the cloudfront.net address which comes when we successfully created the EBS. 2 Change the a record from IP/ElasticLoadBalancer to CloudFront Url