server { listen 80; listen [::]:80; server_name _; root /usr/share/nginx/html; # Logging access_log /var/log/nginx/frontend-access.log main; error_log /var/log/nginx/frontend-error.log warn; # 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; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Gzip compression gzip on; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json application/javascript; gzip_min_length 1000; # Serve static files with SPA fallback location / { try_files $uri $uri/ /index.html; } # Cache static assets (60 days) location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|woff|woff2|ttf|eot)$ { expires 60d; add_header Cache-Control "public, immutable"; } # Don't cache HTML files location ~* \.html$ { expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate"; } # Health check location /health { access_log off; return 200 "OK\n"; add_header Content-Type text/plain; } # Deny access to sensitive files location ~ /\. { deny all; access_log off; log_not_found off; } }