From 6f6179b8c85a7b7143bfd625958e942e681c7864 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 1 Aug 2021 10:15:57 +0200 Subject: Trust reverse proxy when enabled --- webserver.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webserver.js b/webserver.js index 5496f11..f867c74 100755 --- a/webserver.js +++ b/webserver.js @@ -24,6 +24,14 @@ const httpServer = http.Server(app); const io = socketio(httpServer); +if ("NODE_TRUST_PROXY" in process.env && process.env["NODE_TRUST_PROXY"].length > 0) { + console.log("Note: Trusting reverse proxy's X-Forwarded-* headers."); + app.set("trust proxy", "loopback"); +} else { + console.log("Note: Not trusting reverse proxy. Set NODE_TRUST_PROXY to change."); +} + + // const reqlogger = new Logger("request_log.txt"); -- cgit v1.2.3-70-g09d2