events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; upstream backend_api { server backend:8000; } server { listen 80; root /usr/share/nginx/html; index index.html; # SPA fallback - try file first, then fallback to index.html location / { try_files $uri $uri/ /index.html; } location /api/ { proxy_pass http://backend_api/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_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_read_timeout 86400s; } location /wecom/ { proxy_pass http://backend_api/wecom/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } # Cache static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } } }