问题
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.com
and/hello/world
respectively. - However, inside that function, the
Host
header that eventually makes it into the function'sevent.headers.Host
value is never the custom domain. Instead, theHost
header 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