feat: get client ip from x-forwarded-for header if available

Useful for use-cases where Uptime Kuma is running behind a reverse proxy
This commit is contained in:
theS1LV3R 2022-06-23 23:08:04 +02:00
parent ed1f88a852
commit 6f01a448ad
No known key found for this signature in database
GPG Key ID: 1DF76CB829DAE8D4

View File

@ -1677,7 +1677,8 @@ async function shutdownFunction(signal) {
} }
function getClientIp(socket) { 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 */ /** Final function called before application exits */