Start a project

Tool 212 of 244 · Security

Security Headers Generator

Build a Content-Security-Policy from the services your site uses, add the other headers every site should send, and copy them for Cloudflare, Netlify, Apache or Nginx.

Security Headers Generator at a glanceIllustration: 1, What your site uses; 2, processed in your browser; 3, Header config.Security Headers Generator1What your site uses3Header config2In yourbrowser
1 What your site uses 2 processed on your device 3 Header config

Security Headers Generator

Content-Security-Policy

Services your site uses
Edit each directive

Other headers

Permissions-Policy: switch off

Checks

    Turn on a new policy in report-only mode first, use the site for a day, and fix anything the browser console reports before switching it on for real.

    Your headers

    Cloudflare Pages / Netlify (_headers)
    Apache (.htaccess)
    Nginx

    Some browsers save .htaccess without its leading dot. If yours does, rename the file to .htaccess.

    What each header does

    01

    What it does

    A Content-Security-Policy built from presets, plus HSTS, Referrer-Policy, Permissions-Policy and more, for any server.

    • CSP builder with presets for common services
    • Report-only mode for safe testing
    • HSTS with preload warnings
    • Permissions-Policy, Referrer-Policy, nosniff and COOP

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    _headers, .htaccess and Nginx config, with a Copy and a Download button on every result.

    • CSP
    • HSTS
    • Security

    Why it matters

    Security headers are a few lines of server configuration that stop whole classes of attack: injected scripts, clickjacking, downgrades to unencrypted HTTP, and pages leaking their address to other sites. They cost nothing, but most small business sites send none of them.

    The Content-Security-Policy is the most powerful and the easiest to get wrong, because it must list every service your site loads from. Starting from a strict policy and ticking the services you use gets you most of the way, and report-only mode lets you test without breaking anything.

    How it works

    1. InputThe scripts, fonts and frames your site uses
    2. In your browserCSP and other headers assembled
    3. Output_headers, .htaccess or Nginx config

    Where it fits in a designer's workflow

    1. Plan
    2. Design
    3. Build
    4. Test
    5. Launch
    Before launch, and after adding any third-party script.

    By the numbers

    leej.uk's live security headers: 6 of 8 setContent-Security-Policy: Set; Strict-Transport-Security: Set; X-Content-Type-Options: Set; Referrer-Policy: Set; Permissions-Policy: Set; Clickjacking (frame-ancestors or X-Frame-Options): Set; Cross-Origin-Opener-Policy: Not set; Cross-Origin-Resource-Policy: Not setContent-Security-PolicySetStrict-Transport-SecuritySetX-Content-Type-OptionsSetReferrer-PolicySetPermissions-PolicySetClickjacking (frame-ancestors or X-Frame-Options)SetCross-Origin-Opener-PolicyNot setCross-Origin-Resource-PolicyNot set
    Read from the live https://leej.uk/ response at build time: 6 of the 8 headers OWASP lists are set. The two cross-origin isolation headers are missing; they matter most for sites that embed other origins. Source: OWASP Secure Headers Project; MDN: HTTP headers.
    Show the numbers as a table
    HeaderOn leej.uk
    Content-Security-PolicySet
    Strict-Transport-SecuritySet
    X-Content-Type-OptionsSet
    Referrer-PolicySet
    Permissions-PolicySet
    Clickjacking (frame-ancestors or X-Frame-Options)Set
    Cross-Origin-Opener-PolicyNot set
    Cross-Origin-Resource-PolicyNot set

    How to use it

    1. Tick the services your site uses, then adjust any directive by hand.
    2. Set HSTS, Referrer-Policy and the browser features to switch off.
    3. Read the checks and fix anything in red.
    4. Copy the block for your server. Start in report-only mode, then switch it on.

    FAQ

    Will a CSP break my site?

    It can, if it misses a service you use. That's why there's a report-only mode: browsers report what would be blocked in the console without blocking it.

    Should I tick HSTS preload?

    Only once every subdomain works over HTTPS and you're sure you'll never need plain HTTP. Removal from the preload list takes months.

    Why not use 'unsafe-inline'?

    It allows any inline script to run, including injected ones, which removes most of the protection a CSP gives. Move scripts into files instead.

    How do I check my headers after publishing?

    Open your browser's developer tools, reload, and look at the response headers for the page, or use a free scanner such as Mozilla's HTTP Observatory.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk