HTTP Security Headers Cheatsheet
Quick reference for HTTP security headers covering CSP, transport security, framing protection, content-type, referrer policy, permissions, CORS, and deprecated headers
49 commands
default-srcSet default policy for all resource types
Content-Security-Policy: default-src 'self'script-srcRestrict JavaScript loading sources
Content-Security-Policy: script-src 'self' 'nonce-abc123'style-srcRestrict CSS stylesheet loading sources
Content-Security-Policy: style-src 'self' 'unsafe-inline'img-srcRestrict image loading sources
Content-Security-Policy: img-src 'self' data: https:connect-srcRestrict XHR/Fetch/WebSocket connection targets
Content-Security-Policy: connect-src 'self' https://api.example.comfont-srcRestrict web font loading sources
Content-Security-Policy: font-src 'self' https://fonts.gstatic.comframe-srcRestrict sources that can be embedded in iframes
Content-Security-Policy: frame-src 'self' https://www.youtube.comobject-srcRestrict plugin (Flash, etc.) sources
Content-Security-Policy: object-src 'none'base-uriRestrict URLs that can be used in base element
Content-Security-Policy: base-uri 'self'form-actionRestrict form submission target URLs
Content-Security-Policy: form-action 'self'report-uri / report-toSet CSP violation report destination
Content-Security-Policy: default-src 'self'; report-to csp-reportsCSP nonceAllow inline scripts with nonce-based approach
<script nonce="abc123">...</script>CSP hashAllow inline scripts with hash-based approach
script-src 'sha256-base64encodedHash...'strict-dynamicAllow scripts loaded by trusted scripts
script-src 'strict-dynamic' 'nonce-abc123'CSP Report-OnlyReport CSP violations without blocking
Content-Security-Policy-Report-Only: default-src 'self'Strict-Transport-SecurityForce HTTPS connection in browsers
Strict-Transport-Security: max-age=31536000; includeSubDomainsHSTS preloadRegister domain in HSTS preload list
Strict-Transport-Security: max-age=63072000; includeSubDomains; preloadHSTS includeSubDomainsApply HSTS to subdomains as well
Strict-Transport-Security: max-age=31536000; includeSubDomainsHTTPSリダイレクト (Nginx)Redirect HTTP to HTTPS in Nginx
return 301 https://$host$request_uri;HTTPSリダイレクト (Apache)Redirect HTTP to HTTPS in Apache
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]X-Frame-Options: DENYCompletely prevent page embedding in iframes
X-Frame-Options: DENYX-Frame-Options: SAMEORIGINAllow iframe embedding only from same origin
X-Frame-Options: SAMEORIGINCSP frame-ancestorsSuccessor to X-Frame-Options. More flexible frame control
Content-Security-Policy: frame-ancestors 'self' https://trusted.comNginx X-Frame-OptionsSet X-Frame-Options header in Nginx
add_header X-Frame-Options "SAMEORIGIN" always;X-Content-Type-OptionsPrevent MIME type sniffing
X-Content-Type-Options: nosniff正しいContent-Type設定Set accurate Content-Type on responses
Content-Type: application/json; charset=utf-8X-Download-OptionsPrevent IE from auto-executing downloads
X-Download-Options: noopenno-referrerNever send referrer information
Referrer-Policy: no-referrersame-originSend referrer only for same-origin requests
Referrer-Policy: same-originstrict-origin-when-cross-originRecommended. Send only origin for cross-origin requests
Referrer-Policy: strict-origin-when-cross-originno-referrer-when-downgradeNo referrer when downgrading from HTTPS to HTTP
Referrer-Policy: no-referrer-when-downgradeoriginSend only the origin as referrer
Referrer-Policy: origincameraControl access to camera
Permissions-Policy: camera=(self)microphoneControl access to microphone
Permissions-Policy: microphone=()geolocationControl access to geolocation
Permissions-Policy: geolocation=(self)paymentControl usage of Payment Request API
Permissions-Policy: payment=(self)fullscreenControl usage of Fullscreen API
Permissions-Policy: fullscreen=(self)autoplayControl media autoplay
Permissions-Policy: autoplay=(self)interest-cohortDisable FLoC (ad tracking)
Permissions-Policy: interest-cohort=()Access-Control-Allow-OriginSpecify allowed origins
Access-Control-Allow-Origin: https://example.comAccess-Control-Allow-MethodsSpecify allowed HTTP methods
Access-Control-Allow-Methods: GET, POST, PUT, DELETEAccess-Control-Allow-HeadersSpecify allowed request headers
Access-Control-Allow-Headers: Content-Type, AuthorizationAccess-Control-Allow-CredentialsAllow requests with credentials
Access-Control-Allow-Credentials: trueAccess-Control-Max-AgeSpecify preflight response cache duration
Access-Control-Max-Age: 86400Access-Control-Expose-HeadersSpecify response headers exposed to client
Access-Control-Expose-Headers: X-Request-IdX-XSS-Protection (非推奨)Control browser XSS filter. Replaced by CSP
X-XSS-Protection: 0Public-Key-Pins (非推奨)Certificate pinning. Replaced by Certificate Transparency
# 使用しないこと / Do not useExpect-CT (非推奨)Require Certificate Transparency. Browsers handle by default
# TLS 1.3では不要 / Not needed for TLS 1.3X-Permitted-Cross-Domain-Policies (非推奨)Control Flash/Acrobat cross-domain policy. Unnecessary after plugin deprecation
X-Permitted-Cross-Domain-Policies: none