Omnikit
DevFilesMoneyAll tools
Ctrl K
Dev toolsFile toolsMoney calculatorsAll tools
HomeDeveloper toolsSecurity Headers GeneratorNginx Security Headers Generator

Nginx Security Headers Generator

dev

Write the add_header lines that give an nginx site HSTS, CSP and other security headers

Runs in your browser. Nothing you type is sent anywhere. Checked against sources on 17 Oct 2026.

nginx sends a header only when an add_header line asks for it, and a location with its own add_header drops every header set above it. Pick the headers here and copy add_header lines with the always flag, so they are sent on error pages and redirects too. The Strict profile matches the OWASP Secure Headers recommendations; Balanced keeps images from other sites and pop-up logins working.

Next:
  • CSP Evaluator Check a Content-Security-Policy directive by directive and see how scripts get past it
  • HTTP Headers Checker See the status, response headers and redirect chain of any URL, with security checks

How to use Nginx Security Headers Generator

1

Paste or type your input.

2

Choose the options you need.

3

Press Ctrl+Enter, then copy or download.

How Nginx Security Headers Generator works

A web server sends none of the protective headers unless it is told to. Each one closes a specific hole, and getting the syntax right for every server is the slow part. Choose the headers once and copy the snippet for yours.

Header Strict Balanced
Strict-Transport-Security 2 years, subdomains 1 year, subdomains
Content-Security-Policy OWASP starter allows https images
X-Frame-Options DENY SAMEORIGIN
Referrer-Policy no-referrer strict-origin-when-cross-origin
Permissions-Policy 29 features off 6 features off
Cross-Origin-Embedder-Policy require-corp not sent

Server quirks. nginx adds headers only on success codes unless always is given, and a location with its own add_header forgets the ones above it; Apache needs mod_headers. The notes under each snippet say where it goes. Afterwards, test the live site with the HTTP headers checker. Nothing you type leaves the browser.

The rest of the article, and all 6 questions about Security Headers Generator, are on the Security Headers Generator page.

Frequently asked questions

Which security headers should a website send?

At least Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options: nosniff, a framing rule (X-Frame-Options or CSP frame-ancestors) and Referrer-Policy. Permissions-Policy and the cross-origin headers add more protection. The OWASP Secure Headers Project lists 13 recommended headers, and the Strict profile here follows it.

How do I add security headers in nginx?

Add one add_header line per header inside the server block, with the always flag so error pages and redirects get them too, then run nginx -t and reload. Any location block with its own add_header loses every header set above it, so repeat the lines there or use an include file.

What does the HSTS preload list require?

A valid certificate, a redirect from HTTP to HTTPS on the same host, HTTPS on every subdomain, and a Strict-Transport-Security header on the base domain with max-age of at least 31536000 seconds, includeSubDomains and preload. Removal from the list takes months, so only submit when every subdomain is ready.

Is X-Frame-Options still needed with CSP frame-ancestors?

Modern browsers obey frame-ancestors and ignore X-Frame-Options when both are present, but older browsers know only X-Frame-Options. Sending both costs nothing; the generator keeps them consistent, so DENY pairs with frame-ancestors 'none' and SAMEORIGIN with frame-ancestors 'self'.

Sources

  • OWASP Secure Headers ProjectRecommended values (ci/headers_add.json, updated 4 Oct 2026) and headers to remove
  • RFC 6797, HTTP Strict Transport Securitymax-age and includeSubDomains syntax
  • HSTS Preload List Submissionmax-age of at least 31536000, includeSubDomains and preload
  • W3C Permissions PolicyStructured Field Dictionary, feature=() and (self)
  • nginx ngx_http_headers_moduleadd_header ... always and its inheritance rule
  • Apache mod_headersHeader always set

Last verified 17 October 2026.

Rates and rules change; check the source before you rely on a figure.

Still stuck? Ask about Security Headers Generator and anybody who knows can answer. No account needed.

More ways to use Security Headers Generator

  • Security Headers GeneratorChoose HSTS, CSP, framing and more, then copy the nginx, Apache or Vercel config
  • HSTS Header GeneratorBuild a Strict-Transport-Security header and check it against the preload list rules

On the related tools: JWT Decoder – Paste a token to read its header, payload and expiry · Passphrase Generator – Three to ten random words you can actually remember · Bcrypt Generator – Generate a bcrypt hash for a test user or a config file.

Related tools

All developer tools
JWT Decoder, Verifier & EncoderDecode any JWT, verify its signature, and sign new tokens, all in your browserPassword GeneratorStrong random passwords and memorable passphrases, generated on your devicePassword Strength CheckerHow long your password would survive an attack, and exactly what makes it weakHMAC GeneratorHMAC-SHA1, SHA-256, SHA-384 and SHA-512 of text or a file, and signature checksBcrypt Hash and VerifyHash a password with bcrypt at cost 4 to 14, or check a password against a hashTOTP Generator and TesterLive authenticator codes from a secret, a QR code for your app, and a code testerCertificate DecoderRead an SSL certificate, CSR or public key: names, dates, key size and fingerprintsIMEI CheckerCheck an IMEI number’s check digit, see its TAC and serial, and look up the phone model
Was this tool helpful?
Omnikit

Small jobs, done in your browser. Free, fast and private. Files are never uploaded.

Files

  • Compress Image
  • Image to PDF
  • Merge PDF
  • Compress PDF
  • PDF to Word
  • Word to PDF

Dev

  • JSON Formatter & Validator
  • Base64 Encode & Decode
  • JWT Decoder, Verifier & Encoder
  • Password Generator
  • UUID Generator
  • Unix Timestamp Converter

Money

  • SIP Calculator
  • EMI Calculator
  • GST Calculator
  • FD Calculator
  • PPF Calculator
  • Lumpsum Calculator
GuidesQuestionsAboutHow we checkLaw library (beta)PrivacyTermsDisclosureContactMore: Exam practice (UGC NET Paper 1)Runs in your browser. Nothing is uploaded. © 2026 Omnikit (theomnikit.com)