Files
cryptpad/nginx.conf.tmpl
Linus Gasser 565e8c0f97 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.
2026-12-01 09:53:39 +00:00

65 lines
2.0 KiB
Cheetah

# 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;
access_log /var/log/cpad.log;
error_log /var/log/cpad-error.log;
#access_log /dev/null;
#error_log /dev/null emerg;
# Resolve the app at request time via Docker's embedded DNS, so nginx
# doesn't crash at startup when the app task isn't up yet.
resolver 127.0.0.11 valid=10s ipv6=off;
set $cryptpad_upstream http://{{ env "STACK_NAME" }}_app:3000;
# Main CryptPad app
location / {
proxy_pass $cryptpad_upstream;
proxy_set_header Host $host;
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 $forwarded_proto;
proxy_set_header X-Forwarded-Host $forwarded_host;
client_max_body_size 150m;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
}
# WebSocket endpoint
location ^~ /cryptpad_websocket {
proxy_pass $cryptpad_upstream;
proxy_set_header Host $host;
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 $forwarded_proto;
proxy_set_header X-Forwarded-Host $forwarded_host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
}
}