# 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; } }