add support for trustedProxy GATEWAY to determine automatically from gateway. That's useful in docker where an nginx on the host is not always on a known ip.
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-04-02 15:04:28 +02:00
parent 5955e6a71e
commit 2486c98da7
+6 -1
View File
@@ -28,7 +28,12 @@ lasso.configure(require("./marko-config"))
// Set trusted proxy // Set trusted proxy
if (config.trustedProxy != null) { if (config.trustedProxy != null) {
if (ip.isV4Format(config.trustedProxy) || ip.isV6Format(config.trustedProxy)) { if (config.trustedProxy === "GATEWAY") {
const ip = require("child_process").execSync("/sbin/ip route|awk '/default/ { print $3 }'").toString().trim()
app.set('trust proxy', ip)
console.log("Trusting proxy from default gateway", ip);
} else if (ip.isV4Format(config.trustedProxy) || ip.isV6Format(config.trustedProxy)) {
app.set('trust proxy', config.trustedProxy) app.set('trust proxy', config.trustedProxy)
console.log("Trusting proxy", config.trustedProxy); console.log("Trusting proxy", config.trustedProxy);