From 667651cbaf61fa07049ddfa087922d22c97a97f6 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Tue, 9 Jan 2018 15:20:33 +0100 Subject: ip: Use nginx-forwarded address --- modules/ip/ip.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules/ip') 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)); }); }; -- cgit v1.2.3-70-g09d2