I want to host a static website in AWS S3.
Can I enable HTTPS, without buying a domain name? I have a site, and in all the tutorials it requires a domain name.
I want to host a static website in AWS S3.
Can I enable HTTPS, without buying a domain name? I have a site, and in all the tutorials it requires a domain name.
Although there's some discussion in this Stack Overflow thread suggesting that you may access files directly via S3 HTTPS URL, official AWS documentation recommends the use of CloudFront for S3 static website endpoints:
Note The Amazon S3 website endpoints do not support HTTPS.
If you don't want to buy a domain, just keep CloudFront's default. It will look like d111111abcdef8.cloudfront.net.
In case you change your mind and want to set up a custom domain, follow the official documentation.
For the CloudFront configuration, follow the following steps, as described in this premium support blog page:
- Open the CloudFront console.
- Choose Create Distribution.
- Under Web, choose Get Started.
- For Origin Domain Name, you can either choose your S3 bucket's REST API endpoint from the drop-down menu, or you can enter your S3 bucket's website endpoint. For more information, see Key Differences Between the Amazon Website and the REST API Endpoint
- For Viewer Protocol Policy, choose HTTP and HTTPS. Note: Choosing HTTPS Only blocks all HTTP requests.
Hope it helps!
As S3 URLs do not support HTTPs so you need to use another layer, which can be AWS CDN i.e. Cloudfront
AWS suggests to use Cloudfront if you want to add HTTPs support for your static website hosted on S3. Please follow the steps mentioned here
How do I use CloudFront to serve HTTPS requests for my Amazon S3 bucket?
- Open the CloudFront console.
- Choose Create Distribution.
- Under Web, choose Get Started.
- For Origin Domain Name, you can either choose your S3 bucket's REST API endpoint from the drop-down menu, or you can enter your S3 bucket's website endpoint. For more information, see Key Differences Between the Amazon Website and the REST API Endpoint.
- For Viewer Protocol Policy, choose HTTP and HTTPS. Note: Choosing HTTPS Only blocks all HTTP requests.
If you're not using a custom domain with CloudFront, choose Create Distribution to complete the process. If you are using a custom domain, follow these additional steps before you create the distribution:
- For Alternate Domain Names (CNAMEs), type your custom domain.
- For SSL Certificate, choose Custom SSL Certificate. Then, choose the custom SSL certificate to assign to the distribution. Note: For more information on installing a certificate, see How do I install SSL/TLS certificates on Amazon CloudFront?
- Choose Create Distribution. Note: After you choose Create Distribution, it can take about 20 minutes for your distribution to deploy.