2
votes

I'm using Cloudflare for my DNS and have SSL full. I'm trying to set up a subdomain; https://humlor.myrenas.se and point that to an AWS S3-bucket. I have Set up Cloudfront with a Default CloudFront Certificate (*.cloudfront.net) and the site is available at https://d2ufhnw2kk1vh9.cloudfront.net/ (without styling of some absolute paths to the CSS)

I have then created a CNAME record in Cloudflare: CNAME humlor is an alias of d2ufhnw2kk1vh9.cloudfront.net

But https://humlor.myrenas.se/ gives: 403 ERROR The request could not be satisfied. Bad request.

Do I need another certificate in Cloudfront? Or what is missing?

2

2 Answers

7
votes

This error message almost always means the request did arrive at CloudFront, but that CloudFront does not recognize the hostname that was contained in the HTTP headers. This suggests that you overlooked the need to set the Alternate Domain Name in your CloudFront distribution.

If you want to use your own domain name, such as www.example.com, instead of the cloudfront.net domain name that CloudFront assigned to your distribution, you can add an alternate domain name to your distribution for www.example.com.

https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CNAMEs.html

By default, CloudFlare doesn't change the Host header the browser sends, so CloudFront sees your custom domain name in the incoming request, and doesn't know what to do next, because no configured distribution has this name configured as an Alternate Domain Name, so it returns this error.

-1
votes

For "https://humlor.myrenas.se and point that to an AWS S3-bucket": you need route53, by which your URL will be able to point to the s3 bucket (name of the s3 bucket should be humlor.myrenas.se also)

you don't need cloudfront when you got cloud flare...

Your DNS to be on cloud flare, where you map your URL to AWS IP --- AWS route53 takes this URL and points to your s3 bucket and the default page there shows up