diff --git a/nginx.conf.template b/nginx.conf.template index 113273d61..0b0203a48 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -1,3 +1,13 @@ +# The backend needs the real request scheme (DPoP `htu` checks and secure cookies). +# TLS ends at the ingress, so nginx itself sees http and `$scheme` would lie; pass the +# ingress-provided value through and fall back to $scheme only when it is absent. +map $http_x_forwarded_proto $mip_forwarded_proto { + # Only a real https claim counts; normalises HTTPS and chains like 'https,http'. + # Anything else (spoofed or absent) falls back to the container's own $scheme. + ~*^https https; + default $scheme; +} + server { listen 80; server_tokens off; @@ -14,6 +24,7 @@ server { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $mip_forwarded_proto; } # Angular shell route for the notebook page (must not proxy to JupyterHub).