# HTTPS variant of nginx.conf — used by the docker-compose.tls.yml overlay. # nginx terminates TLS and reverse-proxies /api to the backend over the internal network. # Mount a certificate at /etc/nginx/certs/{fullchain.pem,privkey.pem}. # Redirect all plain HTTP to HTTPS. server { listen 80; server_name _; return 301 https://$host$request_uri; } server { listen 443 ssl; http2 on; server_name _; ssl_certificate /etc/nginx/certs/fullchain.pem; ssl_certificate_key /etc/nginx/certs/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; root /usr/share/nginx/html; index index.html; # SPA client-side routing: fall back to index.html location / { try_files $uri $uri/ /index.html; } # Proxy API calls to the backend service (session cookie preserved). # X-Forwarded-Proto=https lets the app (server.forward-headers-strategy=framework) # know the original request was secure → Secure cookies + https redirects. location /api/ { proxy_pass http://app:8080; proxy_http_version 1.1; 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 $scheme; proxy_cookie_path / /; } }