amazon-web-services - 使用 HTTP 代理访问 AWS API Gateway 中的 cloudfront-viewer-country header ?

标签 amazon-web-services aws-api-gateway

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

我需要通过 CloudFront-Viewer-Country头到我的端点。我尝试遵循以下问题中概述的相同设置
Access headers in AWS API Gateway using HTTP Proxy?

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

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

)


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

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

最佳答案

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

然后,在集成请求 → HTTP header → 添加 header 。

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

部署 API。

关于amazon-web-services - 使用 HTTP 代理访问 AWS API Gateway 中的 cloudfront-viewer-country header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46257648/

相关文章:

java - 使用 AWS ApiGateway 签名的 URL

amazon-web-services - 通过 Cloudformation 将 EFS ID 传递给 OpsWorks

amazon-web-services -/usr/bin/env : 'ruby' : No such file or directory userdata in codedeploy ubuntu

amazon-web-services - git 版本控制 lambda 函数

node.js - 如何使用 Spring Cloud 和 Netflix 的 Eureka 注册 Node 应用程序

ios - API 网关 : Empty request body?

aws-lambda - 无服务器项目的最佳文件夹结构是什么?

amazon-web-services - 将 bigrock 上的子域链接到 Amazon EC2 实例

amazon-web-services - 无法访问 AWS EKS 留言簿 URL

amazon-web-services - 使用 "alexa-app"依赖项将 Alexa 技能部署到 AWS Lambda