server { listen 80; root /usr/share/nginx/html; index index.html; # SPA routing — return index.html for all non-file routes location / { try_files $uri $uri/ /index.html; } # Proxy API calls to the backend container # Use Docker's internal DNS resolver so upstream resolves at request time resolver 127.0.0.11 valid=10s; set $api http://api:3001; location /api/ { proxy_pass $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; } }