Enforce the report-only Content-Security-Policy on nginx
Why it matters
A report-only policy reports violations but blocks nothing, so it gives no protection yet. Once its reports are clean, send the same policy as Content-Security-Policy.
Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.
The fix
- Stage 1: check the reports or the developer console until nothing legitimate is reported.
- Stage 2: rename the header in the add_header line (keep always), run sudo nginx -t and reload.
nginx
add_header Content-Security-Policy "<same value as the report-only policy>" always; Related
- Reported by the Content-Security-Policy check
- Add a Content-Security-Policy
- Send the Content-Security-Policy as an HTTP header
- Restrict where scripts can load from
- Replace 'unsafe-inline' scripts with nonces or hashes
- Remove 'unsafe-eval' from script-src
- Remove wildcard sources from script-src
- Set object-src to 'none'
- Add base-uri to the Content-Security-Policy
- Reduce reliance on inline styles
- Fix the Content-Security-Policy syntax
Scan your domain to see whether this applies to you.