简体   繁体   中英

S3 bucket with SSL with static website

I created a bucket and configured a static website hosting

I want to use SSL so instead of using

http://my-bucket.s3-website.us-east-2.amazonaws.com/

I have to use https://s3.us-east-2.amazonaws.com/my-bucket/

the problem with this is that the static website hosting endpoint is still http://my-bucket.s3-website.us-east-2.amazonaws.com/

I created a redirection rule on it (basically if the requested file returns 404 then I call an API) but is not working because (I assume) the endpoint is the bad one and when I try to access a file that doesn´t exist instead of getting the redirection configured in the static website I get Access Denied. how to deal with this?

notes: I tried to use s3-website.us-east-2.amazonaws.com/my-bucket/file.jpg but I get redirected to an amazon page.

I worked at getting SSL working for a static web site on AWS using a custom domain for two days and, having Googled much and stopped by this posting, finally found this excellent and concise tutorial Example Walkthroughs - Hosting Websites on Amazon S3 on AWS at https://docs.aws.amazon.com/AmazonS3/latest/dev/hosting-websites-on-s3-examples.html . While it seems obvious now, the thing that got the SSL working for me was the final step of Update the Record Sets for Your Domain and Subdomain The guide is very to the point, well written and easy to follow so thought this would help others.

Instead of using Cloudfront (or other Amazon services except for S3) you can use this tool: https://github.com/igorkasyanchuk/amazon_static_site which allows you to publish a site and use Cloudflare. You will get https too.

To simplify life you can use a generator and then just edit config and deploy files to S3/Cloudflare.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM