Security headers are short instructions a server sends with every page, asking the browser to enforce protections such as “use HTTPS only” or “don’t let other sites frame me”. They’re public, so anyone can check them in seconds, and if you run a site, most of them take one line each to add.
This guide covers both halves: how to check a site’s headers and judge what you find, and how to set the missing ones on the most common servers and hosts, without breaking anything.
Try it live: check a site’s headers
- Open the HTTP header checker.
- Enter a site, for example
https://myipspot.com, and press Inspect. - Read the status line first. The colored pill shows the final status code: green for 2xx (success), blue for 3xx (redirect), red for 4xx and 5xx (errors).
- Try the same site with
http://at the front. A Redirect chain section appears, showing each hop with its status code. One301hop from HTTP to HTTPS is what you want to see. - Below that is the headers table, with names in lowercase and in alphabetical order. Use the Filter headers box to look for each header in the checklist below: type
strict,content-security,x-frame,nosniff,referrerandpermissionsin turn. No match means the site doesn’t send it.
The checker fetches the page from our server, with no cookies or login. It shows what an anonymous visitor gets, not what your own browser receives, and a site can send different headers to logged-in users. For pages behind a login, use your browser’s developer tools instead.
The checklist: what good looks like
Six headers cover most of what matters. For each one, here’s a sensible starting value and what it means if a site doesn’t send it.
| Header | Good starting value | If it’s missing |
|---|---|---|
| Strict-Transport-Security | max-age=31536000 | Browsers may make the first request over plain HTTP |
| Content-Security-Policy | default-src 'self', plus the sources the site really uses | Injected scripts run like any other script |
| X-Frame-Options | DENY or SAMEORIGIN | Other sites can show the page in a hidden frame |
| X-Content-Type-Options | nosniff | Browsers may guess file types |
| Referrer-Policy | strict-origin-when-cross-origin | Browsers use their own default |
| Permissions-Policy | camera=(), microphone=(), geolocation=() | Features stay available to the page |
Two notes on that table. The frame-ancestors part of a CSP does the same job as X-Frame-Options, so a site that sets it is covered either way. And Referrer-Policy matters less than it used to, because modern browsers already default to strict-origin-when-cross-origin.
How to judge what you find
Online scanners often turn headers into a letter grade. A grade is a quick summary, but it hides the reasons, so it’s more useful to go through the list yourself:
- HTTPS and HSTS first. A one-hop redirect from HTTP to HTTPS plus an HSTS header is the foundation. Without HTTPS, the other headers can be changed in transit.
- CSP next. It’s the hardest to get right and the most protective. A policy containing
'unsafe-inline'for scripts is weaker, but still better than none. - Then the one-liners: frame protection,
nosniff, Referrer-Policy and Permissions-Policy.
Check more than the homepage. Headers added by an application can differ from page to page, and error pages or downloads often skip the ones the main pages get. Run two or three different addresses through the checker, including one that doesn’t exist, to see the site’s 404 page.
For a site you visit, a missing header is a small data point, not a verdict. Firewalls, careful code and the site’s own design all add protection that headers don’t show. For a site you run, each missing header is a to-do item, and the next section shows how to set it.
How to set them on your server or host
Add one header at a time and check it with the header checker after each change. The values below are the starting points from the checklist. Leave CSP for last, because it needs a value built for your own site.
Nginx
Put these lines in the server block, then reload Nginx:
add_header Strict-Transport-Security "max-age=31536000" always;add_header X-Frame-Options "SAMEORIGIN" always;add_header X-Content-Type-Options "nosniff" always;add_header Referrer-Policy "strict-origin-when-cross-origin" always;
The always flag adds the header to error pages too. Watch one trap: if a location block has any add_header line of its own, Nginx drops all the headers from the server block for that location. Repeat them there, or keep every add_header in one place.
Apache
These need the mod_headers module. Add them to your site’s configuration or to .htaccess:
Header always set Strict-Transport-Security "max-age=31536000"Header always set X-Frame-Options "SAMEORIGIN"Header always set X-Content-Type-Options "nosniff"Header always set Referrer-Policy "strict-origin-when-cross-origin"
Netlify and Cloudflare Pages
Both read a plain text file named _headers from your site’s published folder. A line with a path pattern, such as /* for every page, starts a block. Under it, each header goes on its own line, indented by two spaces:
Strict-Transport-Security: max-age=31536000X-Frame-Options: SAMEORIGINX-Content-Type-Options: nosniffReferrer-Policy: strict-origin-when-cross-origin
This site works that way. It’s hosted on Cloudflare Pages, and its headers come from a _headers file, which is why the checker shows them for every page.
Cloudflare in front of another server
If Cloudflare only proxies your site, you can switch on HSTS in the dashboard under SSL/TLS, in the Edge Certificates section. Other headers can be added with a response header transform rule, without touching your server.
Roll out safely
Two headers can lock visitors out if they’re wrong, so introduce them gently.
HSTS. Browsers remember it for the whole max-age, so a mistake can’t be undone quickly. Start with a short value such as max-age=300 (five minutes), confirm the whole site works over HTTPS, then raise it to a year. Add includeSubDomains only when every subdomain has a working certificate, and treat preload as permanent: it asks browsers to build your domain into their HTTPS-only list, and getting removed takes months.
CSP. Send it first as Content-Security-Policy-Report-Only. Browsers then report what the policy would block, in the developer console, without blocking anything. Fix the gaps, then switch to the real header. A broken CSP shows up as missing images, styles or features, not as an error message for visitors.
After every change, run the site through the header checker again, with http:// and with https://, to confirm the headers arrive and the redirect still takes one hop.
Frequently asked questions
Is it legal to check a site’s headers?
Yes. Response headers are sent to everyone who opens a page, so they’re public by design. Checking them is one ordinary request, the same as visiting.
What’s the difference between HTTPS and HSTS?
HTTPS is the encrypted connection. HSTS is a header that tells the browser to always use HTTPS for that site, even when you type or click a plain http:// address. A site can support HTTPS without sending HSTS.
Why do I see fewer headers than in my browser’s developer tools?
The checker fetches the page server to server, without your cookies or login. Sites often add headers for logged-in visitors, and developer tools also show the request headers your own browser sent.
Do security headers help SEO?
Not directly. Google treats HTTPS as a small ranking signal, but it doesn’t reward individual security headers. They protect your visitors, which is reason enough. If you’re also looking at other public setup details, our guide to reading DNS records covers the next layer down, and you can always see what your own IP address reveals.