Search code examples
amazon-cloudfrontamazon-route53

How to use CloudFront with ELB for http to https redirection


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?


Solution

  • 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