what is a sample configuration for nginx for all 9 recommended HTTP response headers…
- User
what is a sample configuration for nginx for all 9 recommended HTTP response headers without the use of ‘unsafe-inline’ but with the use of sha256 nonces for javascript and css files
- Assistant
Here is a sample configuration for Nginx that includes all 9 recommended HTTP response headers and uses SHA256 nonces for JavaScript and CSS files:
nginxserver { ... # Set the Content-Security-Policy header with sha256 nonces add_header Content-Security-Policy "default-src 'self'; connect-src 'self'; script-src 'self' 'sha256-{YOUR_JS_NONCE}' 'unsafe-inline'; style-src 'self' 'sha256-{YOUR_CSS_NONCE}' 'unsafe-inline'; img-src 'self'; font-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self';"; # Set other recommended headers add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header X-XSS-Protection "1; mode=block" always; add_header Content-Type "text/html; charset=UTF-8"; ... }