server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Frontend SPA routing location / { try_files $uri $uri/ /index.html; } # Proxy /api requests to localhost backend location /api/ { proxy_pass http://127.0.0.1:8001/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; } # Proxy websockets/docs if needed location /docs { proxy_pass http://127.0.0.1:8001/docs; } location /openapi.json { proxy_pass http://127.0.0.1:8001/openapi.json; } # Cache static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } }