summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2018-01-09 15:20:33 +0100
committertomsmeding <tom.smeding@gmail.com>2018-01-09 15:20:48 +0100
commit667651cbaf61fa07049ddfa087922d22c97a97f6 (patch)
tree58b1fa5b0ace89c69b67bdadabc8046a19750381 /modules
parenteabe373bb9034a12b721b492b59fedc4a9f242b9 (diff)
ip: Use nginx-forwarded address
Diffstat (limited to 'modules')
-rw-r--r--modules/ip/ip.js4
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));
});
};