If your site is behind Cloudflare, you can add every security header our Security Audit checks for at the edge — without touching your origin server. Cloudflare Transform Rules apply the headers at every PoP globally; Cloudflare's SSL/TLS dashboard handles HSTS and TLS configuration. This guide covers the full set: six HTTP security headers, modern TLS, security.txt, all configured from the Cloudflare dashboard.
Cloudflare has a dedicated HSTS toggle that handles the header globally — don't add HSTS via Transform Rules, use the dedicated control.
X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy and Content-Security-Policy all go into a single Transform Rule for clean management.
Security headershostname eq "yourdomain.com" for tighter control)X-Frame-Options SAMEORIGIN X-Content-Type-Options nosniff Referrer-Policy strict-origin-when-cross-origin Permissions-Policy geolocation=(), microphone=(), camera=() Content-Security-Policy default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; frame-ancestors 'self'Click Deploy. Headers apply globally within seconds.
Cloudflare doesn't have a dedicated security.txt feature. Two clean options:
Create /.well-known/security.txt on your origin server (see the nginx or Apache guides for the file content and Content-Type configuration). Cloudflare proxies it through.
security-txt. Paste:
export default {
async fetch(request) {
const url = new URL(request.url);
if (url.pathname === "/.well-known/security.txt") {
return new Response(
"Contact: mailto:security@yourdomain.com\n" +
"Expires: 2027-05-18T00:00:00.000Z\n" +
"Preferred-Languages: en\n" +
"Canonical: https://yourdomain.com/.well-known/security.txt\n",
{ headers: { "content-type": "text/plain; charset=utf-8" } }
);
}
return fetch(request);
}
};
Deploy.
yourdomain.com/.well-known/security.txtcurl -sI https://yourdomain.com/ | grep -iE "strict-transport|x-frame|x-content|referrer|permissions|content-security" curl -sI https://yourdomain.com/.well-known/security.txt