Skip to main content

Cloudsoft Zone Build, deploy and scale with practical guides to PHP, Node.js, React, DevOps and AI automation. Explore the guides

Cloudsoft Zone
ResourcesResource guide

HTTP security headers checklist: what to send and how to test

The HTTP security headers worth sending in 2026, with OWASP-recommended values, nginx and Helmet configuration, a safe CSP rollout and free ways to test them.

Nilesh Kushvaha

Updated 7 min read

Cloudsoft Zone cover: HTTP security headers checklist: what to send and how to test
Image: Cloudsoft Zone
In this article

Part 6 of 8

A developer's reference kit

All parts

HTTP security headers are a few lines of server configuration that tell browsers to refuse framing, stop guessing content types, insist on HTTPS and limit where scripts can load from. They cost almost nothing to add and are among the first things a security review or penetration test looks at.

An HTTP security headers checklist tells you which headers to send and with which values. The recommendations here follow the OWASP HTTP Headers Cheat Sheet, with configuration for nginx and Helmet on Node.js and free tools to test the result.

This checklist gives you the headers worth sending in October 2026, the values recommended by the OWASP HTTP Headers Cheat Sheet, copy-ready configuration for nginx and Node.js, and free tools to test the result. It is aimed at developers and small teams running their own servers or apps; each item has a short "why" so you can decide rather than copy blindly.

The HTTP security headers checklist at a glance

HeaderRecommended starting valueWhat it protects against
Strict-Transport-Securitymax-age=63072000; includeSubDomains (add preload only deliberately)Downgrade to plain HTTP, cookie theft on insecure connections
Content-Security-PolicyA policy built for your site, starting in report-only modeCross-site scripting and injected third-party code
X-Content-Type-OptionsnosniffBrowsers treating uploaded files as scripts or styles
X-Frame-Options / CSP frame-ancestorsDENY or frame-ancestors 'none'Clickjacking
Referrer-Policystrict-origin-when-cross-originLeaking full URLs (and tokens in them) to other sites
Permissions-Policygeolocation=(), camera=(), microphone=()Embedded code using powerful browser features
Cross-Origin-Opener-Policysame-originCross-window attacks from pages you open or that open you
Cross-Origin-Resource-Policysame-site or same-originOther sites embedding your resources
X-XSS-Protection0 (or omit)Disables a legacy browser filter that caused its own vulnerabilities
Server, X-Powered-ByRemove, or make non-informativeAdvertising your stack and versions

The headers, one by one

Strict-Transport-Security (HSTS)

HSTS tells a browser to use HTTPS for your domain for max-age seconds, even if a user types http://. The OWASP cheat sheet recommends max-age=63072000; includeSubDomains; preload, and warns you to understand the header before using it. includeSubDomains breaks any subdomain still served over plain HTTP, so check internal tools and old marketing subdomains first.

About preload: the HSTS preload list builds your domain into browsers. Its requirements are a redirect from HTTP to HTTPS on the same host, a max-age of at least 31536000 seconds (one year), and both includeSubDomains and preload. The site warns that inclusion "cannot easily be undone" and that removal takes months to reach users through browser updates. Start without preload, run with a long max-age for a while, then submit when you are sure.

Content-Security-Policy (CSP)

CSP is the most powerful header on this list and the only one that needs real design. It lists where scripts, styles, images, frames and connections may come from; anything else is blocked. OWASP calls it "complex to configure and maintain" and has a separate CSP Cheat Sheet.

Roll it out safely with Content-Security-Policy-Report-Only. MDN describes this header as monitoring violations without enforcing the policy, so you can see what would break. Reports go to an endpoint named in Reporting-Endpoints through the report-to directive; MDN notes that report-uri is deprecated but still commonly sent alongside report-to because support for the newer directive is not yet universal.

HTTP
Reporting-Endpoints: csp-endpoint="https://example.com/csp-reports"
Content-Security-Policy-Report-Only: default-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; report-uri /csp-reports; report-to csp-endpoint

Watch the reports for a week or two, adjust the policy, then switch the header name to Content-Security-Policy. Note that the report-only header is not supported in a <meta> element; it must be an HTTP response header.

X-Content-Type-Options, X-Frame-Options and Referrer-Policy

  • X-Content-Type-Options: nosniff stops browsers from second-guessing the Content-Type you send. Pair it with correct content types everywhere, especially for user uploads.
  • X-Frame-Options: DENY prevents your pages from being framed by other sites. OWASP suggests the CSP frame-ancestors directive where possible; sending both is harmless. Use SAMEORIGIN or frame-ancestors 'self' if you frame your own pages.
  • Referrer-Policy: strict-origin-when-cross-origin sends only your origin to other sites, never the full path or query string. OWASP recommends setting it explicitly rather than relying on browser defaults.

Permissions-Policy and the cross-origin headers

Permissions-Policy switches off browser features you do not use, so a compromised third-party script cannot ask for the camera or location. The OWASP example geolocation=(), camera=(), microphone=() disables those three for every origin. Cross-Origin-Opener-Policy: same-origin isolates your browsing context from windows on other origins, and Cross-Origin-Resource-Policy limits who can embed your resources. Cross-Origin-Embedder-Policy: require-corp is only needed if you want cross-origin isolation (for example for SharedArrayBuffer), and OWASP notes it can block misconfigured cross-origin resources, so leave it out unless you need it.

Headers to turn off or remove

OWASP recommends X-XSS-Protection: 0 or not setting it at all; the old browser filter it controlled is gone from modern browsers and could itself be abused. It also recommends removing X-Powered-By and removing or blanking Server. Helmet's documentation is honest that hiding X-Powered-By offers very limited security benefit, but it costs nothing.

Copy-ready configuration

nginx

Two nginx details catch almost everyone. First, add_header only applies to certain success and redirect status codes unless you add the always parameter, so without it your 404 and 500 pages are unprotected. Second, add_header directives are inherited from the enclosing level only if the current level defines none of its own: one add_header inside a location block silently drops all the server-level ones. nginx 1.29.3 added add_header_inherit merge; to change that; on older versions, repeat the headers or keep them in an included file.

Nginx
# /etc/nginx/snippets/security-headers.conf
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains" 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 "geolocation=(), camera=(), microphone=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;
add_header Content-Security-Policy-Report-Only "default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'" always;

# in each server { } block (and any location that has its own add_header):
#   include snippets/security-headers.conf;
server_tokens off;   # removes the nginx version from the Server header

Node.js with Express and Helmet

Helmet (version 8.3.0 on npm in October 2026) sets 13 headers with one line, including a sensible default CSP, X-XSS-Protection: 0 and removal of X-Powered-By. Its defaults differ slightly from OWASP's: for example X-Frame-Options: SAMEORIGIN, Referrer-Policy: no-referrer and HSTS of one year without preload. Override what you need:

JavaScript
import express from 'express';
import helmet from 'helmet';

const app = express();
app.use(helmet({
  contentSecurityPolicy: {
    directives: {
      'script-src': ["'self'"],
      'img-src': ["'self'", 'data:', 'https://images.example.com'],
    },
  },
  strictTransportSecurity: { maxAge: 63072000, includeSubDomains: true },
  referrerPolicy: { policy: 'strict-origin-when-cross-origin' },
}));

We ran this with Express 5 and Helmet 8.3.0 on Node.js 24: the response carried the custom CSP merged with Helmet's defaults, the chosen HSTS and referrer policy, and no X-Powered-By header.

PHP applications and hosted platforms

For PHP sites behind nginx or Apache, set headers in the web server so they also cover static files. If you deploy to a platform, use its own mechanism: Vercel's headers setting in vercel.json or Cloudflare response header transform rules can add the same values at the edge.

How to test your headers for free

curl: see exactly what is sent

Shell
# Headers on the home page
curl -sI https://example.com/

# Headers on an error page (checks nginx's "always")
curl -sI https://example.com/this-page-does-not-exist

MDN HTTP Observatory

The HTTP Observatory on MDN grades a site's headers and related settings. Every site starts at 100, penalties are subtracted, and bonus points are added only if the result is still 90 or more, up to a maximum of 145. It replaced the older Mozilla Observatory, which was sunset in October 2024. There is also a JSON API; its FAQ says a site can be rescanned at most once every 60 seconds:

Shell
curl -s -X POST "https://observatory-api.mdn.mozilla.net/api/v2/scan?host=example.com"

When we ran it for developer.mozilla.org on 9 October 2026 the response reported grade A+, score 110, and 12 of 12 tests passed. Put the API call in CI and fail the build if the grade drops.

What to do next

  1. Run curl -sI against your home page and a 404 page, and note which headers are missing.
  2. Add the low-risk headers first: X-Content-Type-Options, X-Frame-Options, Referrer-Policy, Permissions-Policy and HSTS without preload.
  3. Deploy CSP in report-only mode, collect reports, tighten, then enforce.
  4. Scan with the HTTP Observatory and record the grade in your release checklist.
  5. Revisit after adding any third-party script, analytics tool or embed, because each one changes what your CSP must allow.

Security headers will not fix vulnerable code, but they shrink what an attacker can do with a mistake. An afternoon of configuration buys protection on every page you serve.

Frequently asked questions

  • Which security header should I add first?

    Start with the low-risk ones: X-Content-Type-Options: nosniff, X-Frame-Options, Referrer-Policy and HSTS without preload. Then roll out CSP in report-only mode.

  • Should I submit my domain to the HSTS preload list?

    Only when every subdomain works over HTTPS and you are sure. hstspreload.org warns that inclusion cannot easily be undone and removal takes months to reach users.

  • Is X-XSS-Protection still useful?

    No. OWASP recommends X-XSS-Protection: 0 or omitting it, and relying on a Content Security Policy instead.

  • Why are my nginx headers missing on error pages?

    Without the always parameter, nginx only adds headers to certain success and redirect responses. Add always to each add_header.

  • Why did my headers disappear in one location block?

    nginx inherits add_header directives only if the current level defines none. Repeat them, include a shared snippet, or use add_header_inherit merge; on nginx 1.29.3 or later.

  • Is the MDN HTTP Observatory the same as the old Mozilla Observatory?

    It is its successor. The old Observatory was sunset in October 2024; the MDN version focuses on HTTP data and keeps historic scan results.

Sources

  1. HTTP Security Response Headers Cheat Sheet — OWASP
  2. HTTP Observatory FAQ — MDN
  3. HTTP Observatory tests and scoring — MDN
  4. HSTS Preload List Submission — hstspreload.org (Chromium)
  5. Content-Security-Policy-Report-Only — MDN
  6. Module ngx_http_headers_module — nginx
  7. Helmet README — Helmet

Part 7 of 8: A developer's reference kit

Previous part

New tools, once a week

One short email listing what joined the directory.

The weekly email about new tools and occasional newsletters. Unsubscribe at any time.

Comments

No comments yet. Be the first to join the conversation.

Leave a comment

Every comment is read by a moderator before it appears. Your email address is never published; it is used only to contact you about this comment.

Never published. Used only to contact you about this comment.

Loading the security check…

Comments are moderated before publication.