server { listen 80; root /usr/share/nginx/html; index index.html; # SPA fallback location / { try_files $uri $uri/ /index.html; } # Proxy to backend API (avoids CORS) location /api/ { proxy_pass http://5.0.0.181: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; } # WebSocket proxy location /ws/ { proxy_pass http://5.0.0.181:8090/ws/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_read_timeout 3600s; } # Service Worker e manifest — NUNCA cachear (browser precisa verificar updates) location ~* (sw\.js|workbox-.*\.js|registerSW\.js|manifest\.webmanifest)$ { expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; } # Cache assets versionados por hash (imutáveis) location /assets/ { expires 1y; add_header Cache-Control "public, immutable"; } # Cache outros estáticos (ícones, fontes) location ~* \.(png|svg|ico|woff2)$ { expires 30d; add_header Cache-Control "public"; } gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml; }