使用 HTTP 代理访问 AWS API Gateway 中的 cloudfront-viewer-country 标头?

Sem*_*me1 4 amazon-web-services aws-api-gateway

我正在使用 AWS API Gateway 及其 HTTP 代理。

我需要将CloudFront-Viewer-Country标头传递给我的端点。我尝试按照以下问题Access headers in AWS API Gateway using HTTP Proxy 中概述的相同设置进行尝试

我在端点服务器上收到以下标头。

Array
(
    [host] => example.com
    [Accept] => application/json
    [User-Agent] => AmazonAPIGateway_c8752844lh
    [x-amzn-apigateway-api-id] => c8752844lh
    [X-Amzn-Trace-Id] => Root=1-59bd7a5e-003ef07b3c4c3680299801f1
    [X-Forwarded-For] => xx.xxx.xx.xxx
    [X-Forwarded-Port] => 443
    [X-Forwarded-Proto] => https
    [Connection] => keep-alive

)
Run Code Online (Sandbox Code Playgroud)

然而,CloudFront-Viewer-Country不在其中。如果我使用 lambda 函数而不是 HTTP 代理,我可以看到更多的标头(包括CloudFront-Viewer-Country)。

谁能告诉我如何使用 HTTP 代理访问端点上所需的标头?

Mic*_*bot 7

对于您想要标头的资源和方法,请转到 Method Request ? HTTP 请求标头 ? 添加标题并将名称设置为CloudFront-Viewer-Country. 单击带圆圈的复选标记进行添加。这将标头暴露给执行流程的其余部分。

然后,在集成请求中?HTTP 标头 ? 添加标题。

将名称设置为CloudFront-Viewer-Country并设置映射自method.request.header.CloudFront-Viewer-Country,然后单击带圆圈的复选标记进行添加。这将获取公开的标头并将其添加到转发到后端的请求中。

部署 API。