server { listen 80; server_name localhost; # Cache static assets - this needs to come BEFORE the main location block location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg)$ { root /usr/share/nginx/html; expires 1y; add_header Cache-Control "public, no-transform"; } # Serve static files location / { root /usr/share/nginx/html; index index.html; try_files $uri $uri/ /index.html; } # Enable gzip compression gzip on; gzip_vary on; gzip_min_length 1024; gzip_proxied expired no-cache no-store private auth; gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json; # Security headers add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; # Prevent access to hidden files location ~ /\. { deny all; } }