From 182967e5e0a1df04a8789daab7ff1e0b2dce108d Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 18 Apr 2019 15:15:32 +0200 Subject: [PATCH] Fix unique IPs in the admin panel when using nginx --- rpc.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpc.js b/rpc.js index 9943b0334..904bb0628 100644 --- a/rpc.js +++ b/rpc.js @@ -1531,9 +1531,11 @@ var getActiveSessions = function (Env, ctx, cb) { Object.keys(ctx.users).forEach(function (u) { var user = ctx.users[u]; var socket = user.socket; - var conn = socket.upgradeReq.connection; - if (ips.indexOf(conn.remoteAddress) === -1) { - ips.push(conn.remoteAddress); + var req = socket.upgradeReq; + var conn = req && req.connection; + var ip = (req && req.headers && req.headers['x-forwarded-for']) || (conn && conn.remoteAddress); + if (ip && ips.indexOf(ip) === -1) { + ips.push(ip); } });