diff options
author | tomsmeding <tom.smeding@gmail.com> | 2018-01-09 15:20:33 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2018-01-09 15:20:48 +0100 |
commit | 667651cbaf61fa07049ddfa087922d22c97a97f6 (patch) | |
tree | 58b1fa5b0ace89c69b67bdadabc8046a19750381 | |
parent | eabe373bb9034a12b721b492b59fedc4a9f242b9 (diff) |
ip: Use nginx-forwarded address
-rw-r--r-- | modules/ip/ip.js | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/ip/ip.js b/modules/ip/ip.js index dec0a98..08fcf07 100644 --- a/modules/ip/ip.js +++ b/modules/ip/ip.js @@ -3,6 +3,8 @@ var cmn=require("../$common.js"), module.exports=function(app,io,moddir){ app.get("/ip",function(req,res){ - res.send(String(req.socket.remoteAddress)); + var ip=req.headers["x-forwarded-for"]; + if(ip)res.send(ip); + else res.send(String(req.socket.remoteAddress)); }); }; |