Cloudflare Pages Security Headers
Generate a production-ready Cloudflare Pages `_headers` file with strict CSP, 25/25 ReadyCheck header score, HSTS preload, and immutable `/assets/*` caching.
Configure Django's built-in `SecurityMiddleware` settings (`SECURE_HSTS_SECONDS`, `X_FRAME_OPTIONS`) plus strict Content-Security-Policy and Permissions-Policy.
HTTP Headers: 17/17 pts · TLS/CAA/security.txt: 8/8 pts · COOP/CORP Hardened
# Add inside your HTTPS server {} block
# Target domain: example.com
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests" always;
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 Permissions-Policy "camera=(), microphone=(), geolocation=(), payment=(), usb=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Cross-Origin-Resource-Policy "same-origin" always;
Verify your deployed CSP, HSTS preload, 301 HTTP→HTTPS redirect, DNS CAA, security.txt, DMARC, and AI search readiness in seconds — or grab the $49 ReadyCheck Fix Pack for tailored config bundles.
SECURE_SSL_REDIRECT = True
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
SECURE_HSTS_SECONDS = 31536000
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_HSTS_PRELOAD = True
SECURE_CONTENT_TYPE_NOSNIFF = True
X_FRAME_OPTIONS = "DENY"
SECURE_REFERRER_POLICY = "strict-origin-when-cross-origin"
SECURE_CROSS_ORIGIN_OPENER_POLICY = "same-origin"
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
/.well-known/security.txt after deploy.
Generate a production-ready Cloudflare Pages `_headers` file with strict CSP, 25/25 ReadyCheck header score, HSTS preload, and immutable `/assets/*` caching.
Configure Next.js App Router security headers in `next.config.mjs` with HSTS, X-Content-Type-Options, Permissions-Policy, and strict CSP guidance for hydration scripts.
Generate valid `vercel.json` header arrays for Edge Network routes with HSTS preload, Permissions-Policy, Referrer-Policy, and clickjacking protection.
Copy-paste hardened Nginx `server {}` block directives using `always` so 4xx/5xx error responses also emit HSTS, CSP, nosniff, and frame protection.
Generate a compliant Netlify `_headers` file for static sites and Edge Functions with strict CSP, HSTS preload, Referrer-Policy, and Permissions-Policy.
Protect Astro static builds and SSR adapters (Cloudflare, Vercel, Node) with strict `script-src 'self'`, zero inline event handlers, and 25/25 security headers.
With HTTPS + 301 redirect + CAA + security.txt active, this Django preset scores 25/25 (17/17 from HTTP headers alone). Strict script-src 'self' earns the full 5/5 CSP points.
Django emits HSTS, `nosniff`, `X-Frame-Options`, `Referrer-Policy`, and COOP natively via `django.middleware.security.SecurityMiddleware`, but requires `django-csp` (or Nginx/Cloudflare headers) for CSP and `Permissions-Policy`.
Enter exact origins like https://api.yourdomain.com into the Custom connect-src or script-src fields above. Never add wildcard * or 'unsafe-eval', and verify your live deployment on audit.runglab.dev.