I have a CloudFront distribution abcd1234.cloudfront.net and I've added a custom domain of mysite.com to the distribution.
- The CloudFront distribution's origin:
aaabbbccc.execute-api.us-east-1.amazonaws.com - When I load the page
mysite.com/hello/world, CloudFront is then consuming API Gatewayaaabbbccc.execute-api.us-east-1.amazonaws.com/prod/{proxy+} - the API Gateway path endpoint is invoking a Lambda Function that calls a function like
getPageContent(customDomainName, pagePath)which should bemysite.comand/hello/worldrespectively. - However, inside that function, the
Hostheader that eventually makes it into the function'sevent.headers.Hostvalue is never the custom domain. Instead, theHostheader is alwaysaaabbbccc.execute-api.us-east-1.amazonaws.com.
I want headers.Host to equal mysite.com (or another header to show that the request comes from mysite.com, but no matter what I do, the Host value is always just the origin url.
Edit: I tried whitelisting Host and it caused the site to break completely, with the error about not being able to reach the CloudFront distribution.
来源:https://stackoverflow.com/questions/44741358/get-cloudfront-custom-domain-in-the-headers-of-a-request