Skip to main content
Web Security

OWASP Security Headers Playbook: Copy-Paste Configs for Next.js, Vercel, Cloudflare & Nginx

Deploy the 7 essential OWASP HTTP response headers (HSTS, CSP, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP) across modern stacks.

6 min readUpdated 2026-11-15

The 7 HTTP security headers every B2B domain needs

Enterprise security questionnaires and automated compliance scanners grade your HTTP response headers before signing contracts. Missing HSTS, clickjacking protection, or MIME-sniffing guards are trivial to fix yet frequently overlooked.

Also strip noisy server fingerprints such as X-Powered-By: Next.js or Express (poweredByHeader: false in Next.js) to reduce automated exploit targeting.

Next.js (`next.config.ts`) & Vercel (`vercel.json`)

In Next.js App Router, define global headers() inside next.config.ts and set poweredByHeader: false. If you host static sites or edge routes on Vercel, vercel.json applies the same headers at the edge.

typescript
// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  poweredByHeader: false,
  async headers() {
    return [
      {
        source: '/(.*)',
        headers: [
          { key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubDomains' },
          { key: 'X-Content-Type-Options', value: 'nosniff' },
          { key: 'X-Frame-Options', value: 'DENY' },
          { key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
          { key: 'Permissions-Policy', value: 'camera=(), microphone=(), geolocation=()' },
          { key: 'Cross-Origin-Opener-Policy', value: 'same-origin' },
        ],
      },
    ];
  },
};

export default nextConfig;

Nginx & Cloudflare Transform Rules

On Nginx, add always to every add_header directive so security headers still attach on 4xx and 5xx responses. On Cloudflare, configure a Response Header Transform Rule in Rules → Transform Rules → Modify Response Header.

nginx
# /etc/nginx/snippets/security-headers.conf
server_tokens off;
add_header Strict-Transport-Security "max-age=31536000; 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 "camera=(), microphone=(), geolocation=()" always;
add_header Cross-Origin-Opener-Policy "same-origin" always;

Check if your domain already passes these requirements

Run a 15-second live compliance scan across Privacy, EAA 2025, Email Auth, and Security Headers—or generate exact configs using our 6 free tools.