Build and audit CSP, HSTS, X-Frame-Options and related headers.
The HTTP Security Headers generator builds a set of response headers for hardening a website, and writes them as nginx, Apache or Express code. You start from a Basic, Strict or API preset and then edit the Content-Security-Policy directives and the other headers. It is a starting point for configuring a server, not a full security audit.
Security headers are HTTP response headers that tell the browser to apply extra protections to a page. Content-Security-Policy restricts where scripts, styles, images and frames may load from, which limits the damage of injected markup. Strict-Transport-Security tells the browser to use HTTPS only for a set time. X-Frame-Options and the frame-ancestors directive control whether other sites can embed the page. X-Content-Type-Options set to nosniff stops the browser from guessing content types. Referrer-Policy controls how much of the URL is sent in the Referer header, and Permissions-Policy turns browser features such as the camera on or off. Cross-Origin-Opener-Policy and Cross-Origin-Resource-Policy isolate the page from other origins. They are a defence in depth layer and do not replace safe coding.
Basic is a balanced start for ordinary sites. Strict suits sites that only use their own scripts and styles. API suits endpoints that return data and no HTML.
The frame-ancestors CSP directive is the modern control and takes precedence in current browsers. X-Frame-Options covers older ones.
It signals that you want the domain in browser preload lists so HTTPS is forced from the first visit. Removing a domain from those lists is slow, so enable it only when sure.
No. Headers reduce certain risks, but they do not fix vulnerable code. Test the result in a browser and with a header scanner.
For nginx, inside a server or location block. For Apache, in the config or .htaccess with mod_headers enabled. For Express, before your routes.
No. The text is built in the page and is not sent anywhere.