server { listen 8080; root /usr/share/nginx/html; index index.html; # W19-23: the hub serves TLS by default (self-issued from its own CA -- # see cmd/kryptkeeper/tls.go). proxy_ssl_verify on + trusted_certificate # make nginx actually check that cert rather than tunnel to it blind; # proxy_ssl_name pins the name checked against the cert's SANs to # "kryptkeeper" (the compose service name docker-compose.yml's # KRYPTKEEPER_TLS_SANS includes), independent of whatever the upstream # DNS/Host resolution happens to be. # W30-19: Server-Sent Events. Exact-match so it wins over the /api/ prefix # block below. nginx does not inherit proxy_* between sibling locations, so # the TLS/header directives are repeated. Buffering and caching MUST be off # or heartbeats and events sit in a proxy buffer; the 3600s timeouts keep # the idle-looking stream (15 s heartbeats) from being reaped at the 60 s # default. location = /api/v1/events { proxy_pass https://kryptkeeper:8080; proxy_ssl_trusted_certificate /etc/kryptkeeper/tls/ca.pem; proxy_ssl_verify on; proxy_ssl_verify_depth 2; proxy_ssl_name kryptkeeper; 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_http_version 1.1; proxy_set_header Connection ""; proxy_buffering off; proxy_cache off; proxy_read_timeout 3600s; proxy_send_timeout 3600s; chunked_transfer_encoding on; } location /api/ { proxy_pass https://kryptkeeper:8080; proxy_ssl_trusted_certificate /etc/kryptkeeper/tls/ca.pem; proxy_ssl_verify on; proxy_ssl_verify_depth 2; proxy_ssl_name kryptkeeper; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; # APPEND to (never pass through) X-Forwarded-For: the hub reads it # right-to-left and believes only what a trusted proxy wrote, so the # client's own header must not survive as the last hop. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /healthz { proxy_pass https://kryptkeeper:8080; proxy_ssl_trusted_certificate /etc/kryptkeeper/tls/ca.pem; proxy_ssl_verify on; proxy_ssl_verify_depth 2; proxy_ssl_name kryptkeeper; } location /readyz { proxy_pass https://kryptkeeper:8080; proxy_ssl_trusted_certificate /etc/kryptkeeper/tls/ca.pem; proxy_ssl_verify on; proxy_ssl_verify_depth 2; proxy_ssl_name kryptkeeper; } # OWASP-003: baseline headers for the static dashboard. They sit in this # location only (nginx drops inherited add_header the moment a block # declares its own, and /api/ responses already carry the hub's headers). # The CSP was checked against the Vite build (one module script and one # stylesheet from /assets, no inline script, no eval). style-src keeps # 'unsafe-inline' for component libraries that inject