- Newest
- Most votes
- Most comments
The customer's origin will be receiving the hostname of the origin configured in CLoudFront (which points to the ELB) unless they have configured CloudFront to forward the Host header.
So assume that the public hostname for the website (and the CNAME set up on CloudFront) is www.mysite.com and the ELB's hostname is my-loadbalancer.us-west-2.elb.amazonaws.com. While the client sends:
GET /page HTTP/1.1
Host: www.mysite.com
if the Host header is not forwarded to the origin, the origin will receive:
GET /page HTTP/1.1
Host: my-loadbalancer.us-west-2.elb.amazonaws.com
and if it a not received over HTTPS, the origin probably issues a redirect response by simply concatenating https://, the Host header and the path to give the response:
HTTP/1.1 301 Moved Permanently
Location: https://my-loadbalancer.us-west-2.elb.amazonaws.com/page
CloudFront will return that to the client, and thus the client will go directly to the ELB.
As others have pointed out, you can configure CloudFront to redirect HTTP request to HTTPS, and enforce all requests to the origin to be HTTPS. This will solve the issue since the origin redirection will never be executed.
If the redirection on the origin does additional logic that is needed, you could configure CloudFront to forward the Host header to the origin so it would then redirect to the public hostname, or you could modify the origin store the public hostname as a configuration and to redirect to the public hostname rather than using the Host header.
Relevant content
- asked 2 years ago
- asked 3 years ago
- asked 2 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 2 years ago