server { listen 8080; server_name _; root /usr/share/nginx/html; index index.html; # Hide the nginx version in the Server header (audit L-2) server_tokens off; # Gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript; gzip_min_length 256; gzip_vary on; # Never cache index.html so the latest HTML is always served location = /index.html { include /etc/nginx/snippets/security-headers.inc; add_header Cache-Control "no-cache, no-store, must-revalidate"; add_header Pragma "no-cache"; add_header Expires "0"; try_files $uri =404; } # Cache hashed assets forever (filename contains content hash) location ~* \.(css|js|jpeg|jpg|png|gif|ico|svg|woff2?)$ { include /etc/nginx/snippets/security-headers.inc; add_header Cache-Control "public, max-age=31536000, immutable"; try_files $uri =404; } location / { include /etc/nginx/snippets/security-headers.inc; try_files $uri $uri/ /index.html; } # Custom error pages error_page 404 /index.html; }