- Browser security rules load before your web page. They stop common browser tricks without slowing your site down.
- Add four low-risk rules first:
X-Content-Type-Options: nosniff,Referrer-Policy,X-Frame-OptionsandPermissions-Policy. - Turn on
Strict-Transport-Security(HSTS) only after you know your HTTPS cert renews well on bothwwwand the bare domain. - Test
Content-Security-Policy-Report-Onlyin watch mode first so Google Maps, stats tools and PayFast popups do not break. - Add rules in Nginx or Cloudflare, because static Next.js exports ignore server rules in
next.config.
In this guide (7 sections)6 min read
- 01Essential HTTP security headers decoded in plain language
- 02Enable the four safe baseline headers right away
- 03Deploy Content-Security-Policy (CSP) safely without breaking embeds
- 04Where headers belong: Nginx / Cloudflare edge vs WordPress plugins
- 05Keep the same headers on redirects, forms and 404 pages
- 06Example Nginx and Cloudflare header setups that keep tools working
- 07Frequently asked questions
Essential HTTP security headers decoded in plain language
Before Chrome, Safari or Firefox draws your web page, your server sends a short set of hidden rules. These browser security settings tell the browser which scripts may run, who may frame your site and how to handle HTTPS.
| Header name | Recommended setting | What it protects against |
|---|---|---|
Strict-Transport-Security (HSTS) | max-age=31536000; includeSubDomains (after HTTPS checks) | Stops public Wi-Fi snoops forcing users onto an unencrypted http:// link |
X-Content-Type-Options | nosniff | Stops browsers guessing file types and running bad scripts hidden in images |
X-Frame-Options / CSP | DENY or frame-ancestors 'none' | Stops scammers hiding your login or contact buttons in a hidden frame |
Referrer-Policy | strict-origin-when-cross-origin | Stops full private page links leaking when someone clicks an outside link |
Permissions-Policy | camera=(), microphone=(), geolocation=() | Blocks added widgets from asking for camera, mic or location access |
Enable the four safe baseline headers right away
Many owners hold back on browser settings because they fear locking users out. Four basic rules (X-Content-Type-Options, Referrer-Policy, X-Frame-Options and Permissions-Policy) are safe on almost every site. They lift your safety score right away.
Check HTTPS renewals before setting HSTS to one year
HSTS tells Chrome never to drop back to plain HTTP. It also hides the bypass button if your cert expires. Test a short max-age=3600 first once both www and your bare domain have valid HTTPS, then raise it to 31536000.
Blocking external frames will not hide your Google Map
X-Frame-Options: DENY stops other sites from wrapping your pages inside a hidden frame for click traps. It does not stop you showing a Google Map on your own /contact/ page.
Deploy Content-Security-Policy (CSP) safely without breaking embeds
CSP blocks injected hack scripts and card-skimming code. It gives the browser an exact list of trusted domains allowed to load scripts, fonts, styles and frames on your site.
Turning on a tight CSP list too fast can block Google Tag Manager, embedded maps or PayFast popups. Roll it out in three calm steps:
- Start with
Content-Security-Policy-Report-Only. List your own site ('self') plus your stats, map and payment domains. - Click through each page type, especially forms, FAQs, maps and store checkouts. Watch Chrome DevTools Console for any blocked items.
- Add any missed trusted tools to your list, then switch from
Report-Onlyto live CSP.
Where headers belong: Nginx / Cloudflare edge vs WordPress plugins
Skip heavy WordPress header plugins that slow down PHP requests and miss cached files or PDFs. Put these rules once inside your Nginx server config, Apache file or Cloudflare Transform Rules.
- Nginx or Apache layer: sends the same rules on every HTML page, PDF and form call without extra work.
- Static Next.js tip: pure
output: 'export'sites on Nginx ignore rules insidenext.config.ts. Put them in your live Nginx or Cloudflare setup instead. - Add short notes in your config explaining why each map, stats or payment domain is on your CSP list.
Keep the same headers on redirects, forms and 404 pages
Do not check only your home page. Spot-check your 404 'not found' page, /contact/ form calls and www redirects so your browser settings match everywhere.
Example Nginx and Cloudflare header setups that keep tools working
Seeing a working sample shows how short and light these rules really are. Six simple lines in your web server or Cloudflare setup protect every page without extra plugins.
Here is how to keep maps, stats and payment scripts running safely alongside strong browser rules:
- Check live rules after each deploy with
curl -sI https://www.yourdomain.co.za/ | grep -iE 'strict|content-security|x-frame|nosniff|referrer'. - In Nginx, adding
add_headerinside a static filelocationblock wipes out parent headers unless you include the shared snippet there too. - Never paste giant random CSP strings from the web, because
'unsafe-inline'or wide wildcards weaken real script defence. - Check Chrome DevTools Console when adding a chat widget, CRM form or payment popup so nothing gets blocked by mistake.
Practical Nginx and Cloudflare starter settings
Most business sites need Strict-Transport-Security: max-age=31536000; includeSubDomains (once HTTPS works), X-Content-Type-Options: nosniff, X-Frame-Options: DENY, Referrer-Policy: strict-origin-when-cross-origin and Permissions-Policy: camera=(), microphone=(), geolocation=(). Skip old flags like X-XSS-Protection: 1; mode=block, which modern browsers no longer use.
Allowing Google Analytics, Maps and PayFast inside CSP
In your CSP rule, name exact trusted tools instead of using wide * wildcards. Set default-src 'self', allow https://www.googletagmanager.com for stats, allow frame-src https://www.google.com for your contact map, and keep frame-ancestors 'none' so outsiders cannot frame your pages.
Frequently asked questions
Do missing HTTP security headers hurt Google organic rankings directly?
No, missing HTTP security headers do not trigger a direct penalty from Google. However, leaving browser guardrails off makes it easier for hackers to inject fake scripts or run clickjacking scams on your pages. If your site gets hacked or flagged by Safe Browsing, your search traffic can drop fast.
Will adding CSP break Google Analytics, Tag Manager or WhatsApp links?
Not if you test Content-Security-Policy in Report-Only mode first. Watch mode shows every analytics script, Google Map, payment popup or chat tool your site loads before anything gets blocked. Once those trusted addresses sit on your allowlist, normal WhatsApp links and Google tracking tools keep working without errors.
Do strict framing headers prevent Googlebot or social shares working?
No, blocking frames with X-Frame-Options or frame-ancestors 'none' does not stop Google's scanner or social previews from working. Search engines read your HTML text directly, and WhatsApp, LinkedIn and Facebook still pull your page title and preview image from normal meta tags without needing to frame your site.
Should we keep BOTH X-Frame-Options AND CSP frame-ancestors?
Yes, keeping both is simple and safe. Modern browsers like Chrome, Safari and Edge follow CSP frame-ancestors 'none', while older browsers and basic security scanners still look for X-Frame-Options: DENY. Adding both one-line rules takes seconds and makes sure every browser blocks hidden clickjacking frames consistently.
Can SoftKore check and deploy security headers on an existing server?
Yes, through our website security service we check the headers your site sends today, test which analytics, maps and payment scripts your pages rely on, and add the right rules in Nginx, Apache or Cloudflare without taking your site offline or breaking live enquiry forms.

