# nginx config for the Dialectic SPA. # - Static SPA assets under /; falls back to /index.html for client-side # router (BrowserRouter needs all unknown paths to serve the shell). # - /api/ reverse-proxies to the dialectic-backend container. The compose # service name + port is settable via DIALECTIC_BACKEND env at run time # (default = http://dialectic-backend:8090). We inject it via envsubst # at container start so the same image works for sim + prod. server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Long-lived caching for hashed asset bundles. location /assets/ { access_log off; add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } # SPA fallback: any unknown path serves index.html so React Router # can take over client-side. location / { try_files $uri /index.html; } # API reverse-proxy. Same-origin from the browser's POV so we sidestep # CORS. nginx upstream must point to the dialectic-backend service. # Substitution happens at container start via envsubst (see Dockerfile # entrypoint pattern; for v1 we hard-code the compose default). location /api/ { proxy_pass http://dialectic-backend:8090/api/; 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_read_timeout 30s; } }