CDN Origin Protection: Shielding Your Server

· Mei-Lin Wu · 4 min read

Why Origin Protection Matters

Your CDN provides DDoS protection, WAF, and rate limiting — but only for traffic that goes through the CDN. If an attacker discovers your origin IP, they can bypass all CDN protections by connecting directly to your server.

CDN Security Architecture — Defense-in-depth protection layersCDN Security Architecture — Defense-in-depth protection layers CDN Security Layers — Defense in Depth DDoS Mitigation Web Application Firewall Bot Detection & Rate Limiting SSL/TLS Encryption Origin Server DDoS ✕ Attack ✕ SQLi ✕ PROTECTED
Figure 1: CDN Security Architecture — Defense-in-depth protection layers

How Origin IPs Get Exposed

IP-Based Protection

Configure your origin firewall to only accept connections from CDN IP ranges:

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages
# iptables example for Cloudflare IPs
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do
  iptables -A INPUT -p tcp -s $ip --dport 443 -j ACCEPT
done
iptables -A INPUT -p tcp --dport 443 -j DROP

Major CDNs publish their IP ranges. CloudFront, Cloudflare, Fastly, and Akamai all provide IP lists that you can use in firewall rules.

Header-Based Authentication

Add a shared secret header that the CDN sends with every origin request. Your origin rejects requests without the correct header:

Secure Request Flow — How requests pass through security layersSecure Request Flow — How requests pass through security layers CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: Secure Request Flow — How requests pass through security layers
# CDN sends:
X-Origin-Auth: s3cr3t-t0k3n-value

# Origin nginx:
if ($http_x_origin_auth != "s3cr3t-t0k3n-value") {
    return 403;
}

This works even if the attacker knows your origin IP — without the secret header, the request is rejected.

Origin Certificate Authentication

Use mutual TLS (mTLS) between CDN and origin. The CDN presents a client certificate; the origin verifies it. Without the correct certificate, the TLS handshake fails. This is the strongest origin authentication method.

Cloudflare-Specific Protection

Additional Measures

Testing Origin Protection

Verify your origin is properly protected:

  1. Try connecting to your origin IP directly — should fail or return a generic response
  2. Search your domain on Shodan, Censys, SecurityTrails — verify origin IP is not exposed
  3. Check all subdomains resolve through CDN, not directly
  4. Send a test request without the auth header — should be rejected

External References

References & Standards: W3C Web Performance · HTTP/2 specification