[英]How to make AWS ALB send request origin to lambda
For API Gateway + Lambda, the event that is sent to Lambda contains Origin header which can be used to set the "Access-Control-Allow-Origin" header of the response. For API Gateway + Lambda, the event that is sent to Lambda contains Origin header which can be used to set the "Access-Control-Allow-Origin" header of the response.
ALB event doesn't seem to contain the Origin
header. ALB 事件似乎不包含
Origin
header。 Is there a way to configure ALB to make it forward a request's Origin
header?有没有办法配置 ALB 以使其转发请求的
Origin
header?
This is an example of an ALB event that arrives at Lambda https://docs.aws.amazon.com/lambda/latest/dg/services-alb.html这是到达 Lambda https://docs.aws.amazon.com/lambda/latest/dg/services-alb.ZFC35FDC70D5FC69D269883A822C7A53的 ALB 事件的示例
{
"requestContext": {
"elb": {
"targetGroupArn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/lambda-279XGJDqGZ5rsrHC2Fjr/49e9d65c45c6791a"
}
},
"httpMethod": "GET",
"path": "/lambda",
"queryStringParameters": {
"query": "1234ABCD"
},
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"accept-encoding": "gzip",
"accept-language": "en-US,en;q=0.9",
"connection": "keep-alive",
"host": "lambda-alb-123578498.us-east-2.elb.amazonaws.com",
"upgrade-insecure-requests": "1",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36",
"x-amzn-trace-id": "Root=1-5c536348-3d683b8b04734faae651f476",
"x-forwarded-for": "72.12.164.125",
"x-forwarded-port": "80",
"x-forwarded-proto": "http",
"x-imforwards": "20"
},
"body": "",
"isBase64Encoded": false
}
You can configure an ALB to forward requests that contain a specific header.您可以配置 ALB 以转发包含特定 header 的请求。
To do this去做这个
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.