我试图在AWS环境中获得用户私有IP和公共IP . 基于这个答案(https://stackoverflow.com/a/46021715/4283738)应该有一个 Headers X-Forwarded-For,分离的ips以及论坛(https://forums.aws.amazon.com/thread.jspa?threadID=200198)
但是当我通过API Gateway lambda nodejs v8部署我的api时 . 我已经安装了用于调试的nodejs处理函数参数的事件和上下文可变项的JSON(https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod)我没有得到私有的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 Proxy集成 - True
Function API : https://y0gh8upq9d.execute-api.ap-south-1.amazonaws.com/prod
1 回答
唐't know what makes you stuck in here, correct me if I'错了 . 从Wiki:
我用邮差设置了 Headers 和测试中的X-Forwarded-For:https://imgur.com/a/8QZEdyH