我创建了一个 Lambda,它检查 DynamoDB 表是否存在匹配主机和请求路径的记录,如果找到,则返回到匹配 URL 的重定向。
我的 Lambda 返回此响应,但 ALB 返回 502。
{
"statusCode": 301,
"statusDescription": null,
"headers": {
"Location": "https://www.my-target.co.uk/"
},
"multiValueHeaders": null,
"body": "Redirecting to https://www.my-target.co.uk/",
"isBase64Encoded": false
}
这是我在 CloudWatch 中为 Lambda 函数找到的日志
START RequestId: 8b5a28f2-c56d-4418-a7b9-66ebe0ba2470 Version: $LATEST
[Information] EMG.ApplicationLoadBalancerRequestHandler: Received: GET /
[Information] EMG.ApplicationLoadBalancerRequestHandler: Processing: my-test.net /
[Information] EMG.RedirectManagers.RedirectTableRedirectManager: Fetching item: my-test.net / from table redirect-table
[Information] EMG.ApplicationLoadBalancerRequestHandler: Found: https://www.target.co.uk/ Permanent
END RequestId: 8b5a28f2-c56d-4418-a7b9-66ebe0ba2470
REPORT RequestId: 8b5a28f2-c56d-4418-a7b9-66ebe0ba2470 Duration: 69.59 ms Billed Duration: 100 ms Memory Size: 128 MB Max Memory Used: 39 MB
这是我得到的回应
HTTP/1.1 502
status: 502
Server: awselb/2.0
Date: Thu, 15 Aug 2019 19:13:58 GMT
Content-Type: text/html
Content-Length: 138
Connection: keep-alive
<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>
我找不到任何说我们不能从 Lambda 返回非 200 响应的信息,所以我真的不知道......
您还可以在相关的 GitHub 存储库中找到这个问题:https ://github.com/aws/aws-lambda-dotnet/issues/507