From 565e8c0f97e4bda9b138ae0e30fd43ba46fa4188 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Tue, 24 Nov 2026 09:58:13 +0100 Subject: [PATCH] Cleanup of unused vars and treafike forwarding CryptPad never reads CPAD_HTTP2_DISABLE or CPAD_TRUST_PROXY, so remove them (and the misleading comment) from compose.yml. nginx used to overwrite X-Forwarded-Proto with its own $scheme (http) and X-Real-IP with Traefik's container IP. Pass through the values Traefik sets, falling back to nginx's own when absent, and add X-Forwarded-Host. Bump NGINX_CONF_VERSION to v4. --- abra.sh | 2 +- compose.yml | 4 ---- nginx.conf.tmpl | 29 +++++++++++++++++++++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/abra.sh b/abra.sh index 0e6ed61..ca72195 100644 --- a/abra.sh +++ b/abra.sh @@ -1,6 +1,6 @@ export CONFIG_VERSION=v3 export CONFIG_JS_VERSION=v2 -export NGINX_CONF_VERSION=v3 +export NGINX_CONF_VERSION=v4 export INFRA_JS_VERSION=v1 export SSO_ENTRYPOINT_VERSION=v8 export SSO_JS_VERSION=v3 diff --git a/compose.yml b/compose.yml index fdfe83c..161e4c4 100644 --- a/compose.yml +++ b/compose.yml @@ -11,10 +11,6 @@ services: - CRYPTPAD_ADMIN_KEYS - "CPAD_MAIN_DOMAIN=https://${DOMAIN}" - "CPAD_SANDBOX_DOMAIN=https://${SANDBOX_DOMAIN}" - # Traefik can't use HTTP2 to communicate with cryptpad_websocket - # A workaroung is disabling HTTP2 in Nginx - - "CPAD_HTTP2_DISABLE=true" - - "CPAD_TRUST_PROXY=1" - "CPAD_CONF=/cryptpad/config/config.js" - "RESTRICT_GUEST_ACCESS=${RESTRICT_GUEST_ACCESS:-false}" volumes: diff --git a/nginx.conf.tmpl b/nginx.conf.tmpl index 4f57e1a..5e100bd 100644 --- a/nginx.conf.tmpl +++ b/nginx.conf.tmpl @@ -1,3 +1,22 @@ +# Traefik terminates TLS and sets X-Forwarded-* / X-Real-IP. Pass its values +# through to CryptPad instead of overwriting them with nginx's own view +# (which would be plain http and Traefik's container IP). Fall back to +# nginx's values when the headers are absent. +map $http_x_forwarded_proto $forwarded_proto { + default $http_x_forwarded_proto; + "" $scheme; +} + +map $http_x_forwarded_host $forwarded_host { + default $http_x_forwarded_host; + "" $host; +} + +map $http_x_real_ip $forwarded_real_ip { + default $http_x_real_ip; + "" $remote_addr; +} + server { listen 8083; server_name localhost; @@ -17,9 +36,10 @@ server { proxy_pass $cryptpad_upstream; proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Real-IP $forwarded_real_ip; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto $forwarded_proto; + proxy_set_header X-Forwarded-Host $forwarded_host; client_max_body_size 150m; @@ -33,9 +53,10 @@ server { proxy_pass $cryptpad_upstream; proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Real-IP $forwarded_real_ip; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Proto $forwarded_proto; + proxy_set_header X-Forwarded-Host $forwarded_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; -- 2.54.0