admin管理员组文章数量:1429008
I'm connecting to my app, which is running on an AWS EC2 instance. I'm trying to get the client IP address but it is showing up as 127.0.0.1
I've tried retrieving it with both req.ip
and req.connection.remoteAddress
. Is there a way to get the IP address that's not the localhost IP?
I'm connecting to my app, which is running on an AWS EC2 instance. I'm trying to get the client IP address but it is showing up as 127.0.0.1
I've tried retrieving it with both req.ip
and req.connection.remoteAddress
. Is there a way to get the IP address that's not the localhost IP?
- stackoverflow./questions/19266329/node-js-get-clients-ip I think this guy asked the same question – AzaFromKaza Commented Jan 28, 2015 at 7:02
1 Answer
Reset to default 7If you're proxying requests through something like Nginx, then you can configure express to respect the X-Forwarded-For
header when getting req.ip
:
app.set('trust proxy', 'loopback');
http://expressjs./api.html#app.set
本文标签: JavaScriptNodeJSExpressTrying to get client IP from request objectshows 127001Stack Overflow
版权声明:本文标题:javascript - Nodejs, Express - Trying to get client IP from request object - shows 127.0.0.1 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745516477a2661570.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论