We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
现象:this.ctx.ip 和 this.ctx.request.ip 为空
相关代码可能是: this[EVENT].clientIP
this[EVENT].clientIP
midway/packages/serverless-http-parser/src/http/req.ts
Line 90 in 44fe607
如果在 egg 中配置 config.proxy = true,然后传入 X-Forwarded-For 是能按照约定取到值的
egg
config.proxy = true
X-Forwarded-For
所以猜测是网关和应用之间传漏了
The text was updated successfully, but these errors were encountered:
由于函数内是通过unix domian socket将请求转发给egg处理,这个过程中无法传递socket.remoteAddress,只能开启 proxy 从header中的 X-Forwarded-For 来获取,不过我们进行一下处理,如果开启了proxy就自动把context.ip赋值到X-Forwarded-For上面,不需要再单独传递了
Sorry, something went wrong.
其实是想拿到 socket.ip,想拿到的数据类似是 ['客户端 Chome 的 ip', '自建网关 nginx 的 ip', '阿里云函数网关 ip'] 这样的从外往里的数组
阿里云fc的http触发器传入的Request上面仅有clientIP,所以拿不到太多数据。
refs: https://help.aliyun.com/document_detail/74757.html
所以该怎么解决
echosoar
No branches or pull requests
现象:this.ctx.ip 和 this.ctx.request.ip 为空
相关代码可能是:
this[EVENT].clientIP
midway/packages/serverless-http-parser/src/http/req.ts
Line 90 in 44fe607
如果在
egg
中配置config.proxy = true
,然后传入X-Forwarded-For
是能按照约定取到值的所以猜测是网关和应用之间传漏了
The text was updated successfully, but these errors were encountered: