Browse Source

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.

master 1.7.3
Gisle Aune 4 years ago
parent
commit
2486c98da7
  1. 7
      server.js

7
server.js

@ -28,7 +28,12 @@ lasso.configure(require("./marko-config"))
// Set trusted proxy
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)
console.log("Trusting proxy", config.trustedProxy);

Loading…
Cancel
Save