慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

G
Google Developers Blog
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
人人都是产品经理
人人都是产品经理
美团技术团队
Blog — PlanetScale
Blog — PlanetScale
S
SegmentFault 最新的问题
博客园 - 【当耐特】
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 叶小钗
Google DeepMind News
Google DeepMind News
量子位
罗磊的独立博客
月光博客
月光博客
N
Netflix TechBlog - Medium
大猫的无限游戏
大猫的无限游戏
博客园_首页
P
Proofpoint News Feed
Jina AI
Jina AI
云风的 BLOG
云风的 BLOG
博客园 - 司徒正美
腾讯CDC

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
What are HTTP security headers — and which ones does your...
SecURL · 2026-05-24 · via DEV Community

SecURL

If you run a security scan on your site and it comes back with a wall of warnings about missing headers, the temptation is to either panic or ignore it entirely. Neither helps. Most of these are genuinely straightforward to fix — the tricky part is knowing which ones actually matter and why.

Strict-Transport-Security is the one I'd add first. It tells browsers to only ever connect to your site over HTTPS, even if someone types http:// or follows an old link. Without it, there's a class of attack on public WiFi where someone can intercept the initial unencrypted request before your site redirects to HTTPS. One header, five minutes to add, never think about it again.

For nginx:

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

Enter fullscreen mode Exit fullscreen mode

X-Content-Type-Options: nosniff is the boring one that everyone should have. Browsers sometimes try to guess what type of file they've been served — a behaviour called MIME sniffing — which can be exploited if your site accepts file uploads. Setting this header tells the browser to just trust what the server says the file is. It's one line and the risk of not having it only goes up if you let users upload things.

X-Frame-Options prevents your pages from being embedded in iframes on other domains. The attack this protects against is clickjacking — your login page loaded invisibly inside someone else's site, with fake UI overlaid to trick users into clicking things they didn't mean to. DENY is the safest setting. If you need to allow specific origins, use the newer frame-ancestors directive in your Content Security Policy instead, which gives you more control.

Referrer-Policy is one most people skip because it sounds unimportant. When a user clicks a link from your site to another site, the browser sends a Referer header containing the full URL they came from. If your URLs contain anything sensitive — user IDs, session tokens, internal paths — those are being leaked to every external site your users navigate to. strict-origin-when-cross-origin is a sensible default that sends the origin but drops the path for cross-site requests.

Content Security Policy is the powerful one and also the annoying one. It lets you define exactly which scripts, styles, images and other resources are allowed to load on your page. Done properly, it stops XSS attacks even if an attacker manages to inject content — they still can't run arbitrary scripts because those scripts aren't on your allowlist.

The catch is that if you use third-party scripts (analytics, chat widgets, fonts, anything), you need to explicitly allow them, which turns into a bit of a project the first time. The way to approach it without breaking your site is to start in report-only mode:

Content-Security-Policy-Report-Only: default-src 'self'; ...

Enter fullscreen mode Exit fullscreen mode

This logs violations without blocking anything. You can see exactly what would break, adjust the policy, then switch to enforcing it once you're confident.

Beyond HTTP headers, the email-related DNS records are just as important and often completely missed. SPF and DMARC together control whether other mail servers will accept email claiming to be from your domain. Without them, anyone can send phishing emails that appear to come from you. Your bank, your customers, anyone. The fix is adding a few DNS records — your email provider (Google Workspace, Postmark, whoever) will give you the exact values to add.

The headers themselves take an afternoon to add. CSP takes longer if you have a lot of third-party dependencies, but you can ship the others immediately and tackle CSP properly as a separate piece of work.

If you want to see where your site currently stands, I built SecURL for exactly this — paste a URL and get a graded report with everything ranked by priority. Free, no account needed.