worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # Gzip compression gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_min_length 1000; gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript application/xml application/xml+rss image/svg+xml font/woff font/woff2; server { listen 80; server_name _; root /usr/share/nginx/html; index index.html; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; # SPA routing: all routes fall back to index.html location / { try_files $uri $uri/ /index.html; } # No cache for index.html (ensures updates are picked up) location = /index.html { add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; } # Long cache for Flutter assets (content-hash naming ensures freshness) location ~* \.(js|css|woff|woff2|ttf|eot|ico|png|jpg|jpeg|gif|svg|webp)$ { expires 1y; add_header Cache-Control "public, immutable"; access_log off; } # Cache manifest and version files briefly location ~* \.(json|webmanifest)$ { expires 1h; add_header Cache-Control "public"; } # Health check endpoint location /health { access_log off; return 200 "OK"; add_header Content-Type text/plain; } } }