General

What Are Security Headers, and Why Does Your Website Need Them?

What Are Security Headers, and Why Does Your Website Need Them?

When someone opens a page on your website, your server sends more than the page. It also sends a few lines of instructions to the visitor's browser, called headers. Nobody sees them, but some of them, the security headers, tell the browser how to protect your visitors: always use a secure connection, refuse scripts from places you didn't approve, and don't let another site disguise your pages.

Most small business websites are missing some or all of them. That's rarely a decision anyone made. Many hosting plans, website builders and frameworks simply don't turn them on, and nobody checks. This post explains what security headers are, what the six that matter do, and how to find out where your site stands.

Why website security headers matter to a small business

You might reasonably think that nobody would bother attacking a plumber's or a dentist's website. Most attacks aren't personal, though. Automated tools scan millions of sites looking for easy openings, and a small site with no protections is exactly what they're looking for. When one gets through, the damage lands on your customers: a fake payment form, a redirect to a scam site, or a page that quietly collects what visitors type.

Security headers don't fix every problem, but they shut down whole kinds of attack at the browser, before they can reach your visitors. They also have three things going for them that few security measures do:

  • They're free. No plugin to buy and no service to subscribe to. They're a few lines of server configuration.
  • They're invisible. Your site looks and works the same. Visitors never see them.
  • They're public. Anyone can check your headers in seconds, including a customer's IT person, an insurance assessor, or a competitor trying to sell you SEO. A missing header is an easy point for someone else to make about your site.

The six security headers that matter

1. Strict-Transport-Security (HSTS)

Your site probably already has an SSL certificate, the padlock in the address bar. But if someone types your address without "https://", or clicks an old link that starts with "http://", their browser's first request goes out unprotected. On public Wi-Fi, that first request can be intercepted.

HSTS tells the browser: for the next year, only ever connect to this site securely. After the first visit, the browser won't even try the insecure version.

Strict-Transport-Security: max-age=31536000; includeSubDomains

The number is in seconds; 31,536,000 is one year. A very short value, such as a day, gives much less protection, because the browser forgets almost as soon as it learns.

2. Content-Security-Policy (CSP)

This is the most powerful header and the one that takes the most care. A Content-Security-Policy lists the places your pages may load scripts, styles, images and frames from. If an attacker manages to inject a script into your page, through a vulnerable plugin or a hacked contact form, the browser refuses to run it, because it isn't on the list.

Content-Security-Policy: default-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'

A strict policy can break things. If your site uses Google Analytics, a chat widget, a booking tool or embedded videos, each of those sources has to be allowed. That's why CSP is often the last header a site adds, and why it's worth testing before you switch it on. Many sites start with a policy that still allows inline scripts ('unsafe-inline') while they tidy up older code. That's much better than no policy, but it isn't the finished job.

3. X-Frame-Options

This header stops other websites from loading your pages inside a hidden frame. Without it, an attacker can lay your real page under a fake one and trick visitors into clicking buttons they can't see, a trick called clickjacking.

X-Frame-Options: DENY

Use SAMEORIGIN instead of DENY if your own site frames its own pages. A Content-Security-Policy with a frame-ancestors rule does the same job in newer browsers.

4. X-Content-Type-Options

Browsers sometimes try to be helpful and guess what kind of file they've been sent. Attackers abuse that by uploading something that looks like an image but gets treated as a script. This one-word header turns the guessing off.

X-Content-Type-Options: nosniff

5. Referrer-Policy

When a visitor clicks a link from your site to another one, their browser tells the other site which page they came from. Sometimes that address contains things it shouldn't: a search term, an order number, a password-reset link. Referrer-Policy limits what gets shared.

Referrer-Policy: strict-origin-when-cross-origin

With this setting, other sites learn only your domain name, not the full page address.

6. Permissions-Policy

Modern browsers can give websites access to the camera, microphone, location and more. Your site almost certainly doesn't need any of them. Permissions-Policy switches them off, so even a script that slips in can't ask for them.

Permissions-Policy: camera=(), microphone=(), geolocation=()

What about X-XSS-Protection?

You'll still see older guides recommend X-XSS-Protection: 1; mode=block. Ignore them. That header controlled a filter that the major browsers have since removed, and in older browsers the filter could itself be abused. Today the advice is to send X-XSS-Protection: 0 or leave it out, and rely on a Content-Security-Policy instead.

How to check your website's security headers

You don't need to read server logs or open developer tools. Our free security headers check reads one page of your site the way a browser does and gives you an A+ to F grade in a few seconds. It shows which headers are present, which are missing or weak, and the exact line to add for each one.

Here's roughly what the grades mean:

  • A+ or A: all six headers in place. An A usually means one setting could be tighter, most often a Content-Security-Policy that still allows inline scripts.
  • B or C: the basics are there but one or two important headers are missing. Many hosting platforms land here by default.
  • D or F: most protections are missing, or the site isn't served over HTTPS at all.

How to add security headers

Headers are set where your site is served, not on the pages themselves. Where that is depends on how your site is hosted:

  • Apache hosting (common on shared plans): lines such as Header always set X-Content-Type-Options "nosniff" in the site's .htaccess file.
  • Nginx: add_header lines in the server configuration, with the always flag so they're also sent on error pages.
  • Cloudflare or another CDN: a response-header rule in the dashboard, with no change to the server.
  • WordPress: a security plugin can add most of them, or your host can add them at the server.
  • Hosted builders (Wix, Squarespace and similar): you usually can't change them yourself. The platform decides.

Five of the six headers take a few minutes to add and almost never cause problems. Content-Security-Policy needs testing first: add it, click through every page and form, and check that nothing has stopped working.

Headers are one piece of the picture

Security headers are a quick, visible sign of whether anyone is looking after a website. They aren't the whole story. Outdated plugins, an expired certificate, a contact form that doesn't work, or email settings that let scammers send mail in your name can all do more damage, and none of them show up in a header check.

That's what our free website evaluation is for. It looks at your whole site, including security, speed on phones, how Google sees you, accessibility and email setup, and gives you a plain-English list of what to fix first. Security headers are part of it, graded the same way as the quick check.

And if you'd rather not deal with any of this yourself: every site Premier Code hosts gets these headers set up and kept up to date as part of our managed hosting. Tell us about your site, and we'll tell you honestly what it needs.

Brian Hurley

Premier Code, Inc.

Related Articles

General
The ROI of a Professional Website for Trade Businesses

Is a professional website worth the investment for your trade business? The math says yes — decisively. Learn how to calculate your website ROI with real numbers, see what drives high returns, and understand why trade businesses with professional sites consistently outgrow their competitors.

General
Mobile-First Web Design: Why 70% of Your Customers Are on Their Phone

Over 70% of your potential customers visit your website from their phone. If your site isn't built mobile-first, you're losing leads, rankings, and revenue every day. Learn the five essential elements of mobile-first design and how to audit your site today.

General
How Service Businesses Are Losing Customers to Competitors Who Show Up Online

Your competitors aren't doing better work — they're just easier to find. Discover the five ways service businesses silently lose customers to competitors who show up online, and get a prioritized action plan to stop the bleeding.

Ready to Grow Your Business Online?

Get a free, comprehensive audit of your business website and learn exactly what to improve.

Get Your Free Website Audit