From b3677ab3db379aae3bfe55352e270f81e24843f2 Mon Sep 17 00:00:00 2001 From: Wei Date: Sun, 15 Dec 2024 20:48:39 +0800 Subject: [PATCH] feat(Docker): expose a SKIP_X_FORWARD_HEADERS option (#75) --- .env.dist | 1 + docker-compose.gluetun.yml | 2 ++ docker-compose.simple.yml | 2 ++ src/routers/qbit/index.js | 2 +- 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.env.dist b/.env.dist index 51a46a9..142180d 100644 --- a/.env.dist +++ b/.env.dist @@ -4,4 +4,5 @@ QBIT_BASE=http://host.docker.internal:8080 RELEASE_TYPE=stable UPDATE_VT_CRON=0 * * * * USE_INSECURE_SSL=false +SKIP_X_FORWARD_HEADERS=false VUETORRENT_PATH=/vuetorrent \ No newline at end of file diff --git a/docker-compose.gluetun.yml b/docker-compose.gluetun.yml index 38e1ef6..2590cff 100644 --- a/docker-compose.gluetun.yml +++ b/docker-compose.gluetun.yml @@ -56,5 +56,7 @@ services: - UPDATE_VT_CRON=0 * * * * # Only enable if using self-signed certificates # - USE_INSECURE_SSL=true + # Only enable if backend container is behind a proxy server which already add x-forward headers + # - SKIP_X_FORWARD_HEADERS=true volumes: - "./data/config:/config" diff --git a/docker-compose.simple.yml b/docker-compose.simple.yml index 54d8491..1b461a5 100644 --- a/docker-compose.simple.yml +++ b/docker-compose.simple.yml @@ -38,6 +38,8 @@ services: - UPDATE_VT_CRON=0 * * * * # Only enable if using self-signed certificates # - USE_INSECURE_SSL=true + # Only enable if backend container is behind a proxy server which already add x-forward headers + # - SKIP_X_FORWARD_HEADERS=true ports: - "8080:8080" volumes: diff --git a/src/routers/qbit/index.js b/src/routers/qbit/index.js index 22a1b33..af5861e 100644 --- a/src/routers/qbit/index.js +++ b/src/routers/qbit/index.js @@ -6,7 +6,7 @@ const router = Router() router.use((req, res, next) => { const proxy = httpProxy.createProxyServer({ host: process.env.QBIT_BASE, - xfwd: true, + xfwd: process.env.SKIP_X_FORWARD_HEADERS !== 'true', secure: process.env.USE_INSECURE_SSL !== 'true', }) proxy.web(req, res, { target: `${process.env.QBIT_BASE}/api` }, next)