Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does one find real Host when using Cloudfront?

In what seems to be a very weird choice, Cloudfront sets the Host header to the origin server host that you specify when forwarding a request.

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/RequestAndResponseBehaviorCustomOrigin.html

Why is this? More importantly, when using wildcard subdomains, how do I know which subdomain the request is from, when they all forward to the same origin?

like image 219
Sudhir Jonathan Avatar asked Apr 21 '14 12:04

Sudhir Jonathan


People also ask

Where is Amazon CloudFront hosted?

CloudFront has servers located in Europe (United Kingdom, Ireland, The Netherlands, Germany, Spain), Asia (Hong Kong, Singapore, Japan, Taiwan and India), Australia, South America, Africa, and several major cities in the United States. In July 2020, the service operated from 205 edge locations on six continents.

How can you tell if a site is using CloudFront?

How do I check if a site has a cdn? In order to check if AWS Cloudfront (CDN) is being used, just look for an x-cache response header. It will say have a mention of the Cloudfront (ie. Hit from Cloudfront or Miss from Cloudfront).

What does a CloudFront URL look like?

Uses the CloudFront domain name in URLs for your objects (for example, https://d111111abcdef8.cloudfront.net/index.html )

Does CloudFront have an IP address?

CloudFront doesn't support assigning a static IP address to distributions. When a user requests content from CloudFront, DNS returns 4 IP addresses of the edge location with the lowest latency.


1 Answers

Good news- cloudfront supports host header forwarding now. It's listed very deep in the documentation:

Host [header]: CloudFront sets the value to the domain name of the origin that is associated with the requested object.

Presumably, all you need to do is ensure header forwarding is enabled in the Default Cache Behavior Settings:

header forwarding configuration in cloudfront

like image 114
tedder42 Avatar answered Oct 17 '22 12:10

tedder42