【发布时间】:2019-05-11 01:58:21
【问题描述】:
我正在尝试在 AWS 环境中获取用户的私有 IP 和公共 IP。基于这个答案 (https://stackoverflow.com/a/46021715/4283738) 应该有一个标题 X-Forwarded-For ,分隔的 ips 以及来自论坛 (https://forums.aws.amazon.com/thread.jspa?threadID=200198)
但是当我通过 API Gateway + lambda + nodejs v8 部署我的 api 时。我已经为用于调试的 nodejs 处理程序函数参数 (https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod) 排除了事件和上下文变量的 JSON 我没有得到私有 ips。
lambda 函数是
const AWS = require('aws-sdk');
exports.handler = function(event, context, callback){
callback(null, {
"statusCode": 200,
"body": JSON.stringify({event,context})
});
}
API 网关详细信息
GET - 集成请求
集成类型——Lambda函数
使用 Lambda 代理集成 -- 是的
函数API:https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod
【问题讨论】:
标签: node.js amazon-web-services aws-lambda aws-api-gateway