server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html index.htm; # Compresión gzip para alto rendimiento gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied any; gzip_types text/plain text/css text/xml application/json application/javascript application/xml+rss application/atom+xml image/svg+xml; # Encabezados de Seguridad add_header X-Frame-Options "SAMEORIGIN" always; add_header X-XSS-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Enrutamiento SPA React location / { try_files $uri $uri/ /index.html; } # Caché estática para assets generados por Vite location ~* \.(?:css|js|woff2?|svg|gif|png|jpg|jpeg|ico)$ { expires 1y; add_header Cache-Control "public, max-age=31536000, immutable"; } # Proxy inverso para llamadas al Backend Fastify location /api/ { proxy_pass http://backend:3001; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; 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; } location /health { proxy_pass http://backend:3001/health; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }