Home > Software design >  Why my AWS S3 bucket redirecting to HTTPS not working?
Why my AWS S3 bucket redirecting to HTTPS not working?

Time:12-28

I have my custom domain (file.example.com) hosted in Namecheap and DNS. Now I have AWS S3 bucket which I am trying to point to my custom domain (file.example.com). What I did is that I have set all the properties and permissions in AWS S3 bucket as well as created Cloudfront distribution to redirect my custom domain to Https. Now I can access every objects using my custom domain URL (file.example.com/sample.pdf), but the HTPPS is not working inspite of creating Cloudfront distribution and generating SSL certificate.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

CodePudding user response:

Based on the discussion over chat, it seems the CNAME for your sub-domain file.example.com is pointing to the S3 bucket URL instead of CloudFront.

Because I can not see CloudFront anywhere in the response headers. Can you please update that and then try?

CodePudding user response:

Redirection for HTTP to HTTPS is handled in the Behavior settings for the distribution. In your CloudFront console, open up your distribution to where you took that screenshot. At the top of the page, you'll see a horizontal navbar. Click the Behavior entry. You'll likely only have one entry. Click the radio button, and go to Edit. The setting you'll be looking for is the Viewer protocol policy which needs to be set to Redirect HTTP to HTTPS (see below).

It may take a few minutes after saving the changes for the update to be made to the CloudFront network.

enter image description here

  • Related