From 6f01a448ad295685d457c7394bd660c0a566ce44 Mon Sep 17 00:00:00 2001 From: theS1LV3R Date: Thu, 23 Jun 2022 23:08:04 +0200 Subject: [PATCH] feat: get client ip from x-forwarded-for header if available Useful for use-cases where Uptime Kuma is running behind a reverse proxy --- server/server.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/server.js b/server/server.js index 2d3f37eeb..e74abafff 100644 --- a/server/server.js +++ b/server/server.js @@ -1677,7 +1677,8 @@ async function shutdownFunction(signal) { } function getClientIp(socket) { - return socket.client.conn.remoteAddress.replace(/^.*:/, ""); + return socket.client.conn.request.headers["x-forwarded-for"] + || socket.client.conn.remoteAddress.replace(/^.*:/, ""); } /** Final function called before application exits */