server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Serving static files from Flutter build location / { try_files $uri $uri/ /index.html; # Fallback to index.html for SPA routing } # Caching static assets for better performance location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|js|json|wasm)$ { expires 1y; access_log off; add_header Cache-Control "public"; } # Handling CORS for Flutter web location ~* \.(js|json|wasm)$ { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, HEAD'; } # Logging configuration access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; }