HTTPS / TLS CRITICAL
Transport Layer Security (TLS) encrypts the HTTP channel. TLS 1.3 (RFC 8446, 2018) is the current standard — 1-RTT handshake, forward secrecy via ephemeral keys, removed weak cipher suites. Always prefer TLS 1.3; disable 1.0 and 1.1.
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
HSTS — HTTP Strict Transport Security HEADER
Instructs browsers to only connect via HTTPS for a specified duration. Prevents SSL-stripping attacks. Include subdomains and preload for maximum protection.
Strict-Transport-Security:
max-age=31536000;
includeSubDomains;
preload
CSP — Content Security Policy HEADER
Restricts the sources from which scripts, styles, images, and other resources can be loaded. The primary defense against XSS attacks. Violations can be reported via report-uri.
Content-Security-Policy:
default-src 'self';
script-src 'self' 'nonce-{random}';
img-src 'self' data:;
report-uri /csp-report
CORS — Cross-Origin Resource Sharing HEADER
Browser mechanism that controls which origins can access a resource. Preflight OPTIONS requests check permissions. Set Access-Control-Allow-Origin to specific domains, never * with credentials.
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST
Access-Control-Allow-Headers: Authorization
Access-Control-Allow-Credentials: true
SameSite Cookies CSRF DEFENSE
Cookie attribute preventing CSRF by controlling when cookies are sent cross-site. Strict = never cross-site; Lax = safe methods only; None = always (requires Secure). Default is Lax in modern browsers.
Set-Cookie: session=abc123;
HttpOnly; Secure;
SameSite=Strict;
Path=/; Max-Age=86400
X-Frame-Options / CSP frame-ancestors CLICKJACKING
Prevents your page from being embedded in an iframe on another origin — defends against clickjacking attacks. X-Frame-Options is legacy; use CSP frame-ancestors instead which supports allowlists.
X-Frame-Options: DENY
# Modern equivalent:
Content-Security-Policy:
frame-ancestors 'none';
X-Content-Type-Options MIME SNIFF
Prevents browsers from MIME-sniffing a response away from the declared Content-Type. Stops attackers from tricking browsers into treating uploaded files as executable content.
X-Content-Type-Options: nosniff
Certificate Transparency & OCSP Stapling PKI
Certificate Transparency (CT) logs all issued certs in public, auditable logs — browsers require CT for trust. OCSP Stapling allows the server to cache and deliver the certificate revocation status, improving privacy and performance.
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 valid=300s;
# CT enforced by browsers automatically
Permissions-Policy & Referrer-Policy PRIVACY
Permissions-Policy (formerly Feature-Policy) controls access to browser APIs like camera, microphone, geolocation. Referrer-Policy limits how much URL info is sent in the Referer header to third-party sites.
Permissions-Policy:
camera=(), microphone=(), geolocation=()
Referrer-Policy:
strict-origin-when-cross-origin