CDN Security Features: DDoS Protection, WAF, and Bot Management
Modern CDNs have long surpassed being mere acceleration tools, becoming the first line of defense for website security. Acting as a reverse proxy, CDNs can intercept large amounts of malicious traffic and protect origin servers. This article provides an in-depth analysis of CDN security capabilities.
1. CDN Security Overview
CDN provides security protection because it acts as an intermediary between users and origin servers:
User → CDN Node → Security Inspection → Origin Server
↓
DDoS Scrubbing, WAF Filtering, Bot Detection
All requests first reach the CDN node. After security inspection, only legitimate requests are forwarded to the origin server. This means attackers cannot directly attack the origin.
2. DDoS Protection
2.1 DDoS Attack Types
| 攻击类型 | 说明 | CDN 应对方式 |
| ------ |
|---|
| Layer 3/4 attacks |
| Layer 7 attacks |
| DNS amplification |
| Slow application attacks |
2.2 CDN DDoS Protection Capabilities
DDoS protection capabilities of different CDN vendors:
| CDN vendor | Protection capacity | Free tier |
|---|---|---|
| Cloudflare | Unlimited (limited in Free) | Basic DDoS protection |
| Alibaba Cloud CDN | Up to Tbps | Pay per scrubbing volume |
| Tencent Cloud CDN | Up to Tbps | Pay per scrubbing volume |
| AWS Shield | Free standard + Advanced plan | Standard auto-enabled |
2.3 DDoS Protection Configuration Tips
# Cloudflare Rate Limiting Configuration (Pro and above)
# Limit each IP to a maximum of 100 requests per 10 seconds
rate_limit {
characteristics: ["cf.connecting_ip"];
period: 10;
requests_per_period: 100;
mitigation_action: "block";
}
3. Web Application Firewall (WAF)
3.1 What WAF Can Defend Against
| Attack type | Description |
|---|---|
| SQL injection | Blocks malicious DB queries |
| XSS | Blocks injected malicious scripts |
| Command injection | Blocks system command execution |
| Path traversal | Blocks directory traversal |
| File inclusion | Blocks local/remote file inclusion |
| CSRF | Cross-site request forgery protection |
| OWASP Top 10 | Covers major web security threats |
3.2 WAF Configuration Examples
Cloudflare WAF Configuration:
Rule examples:
- If request URI contains /wp-admin/ and source IP not in whitelist → Block
- If request contains SQL injection patterns (SELECT.*FROM, UNION SELECT etc.) → Block
- If request User-Agent is empty or abnormal → Challenge (CAPTCHA)
- If request rate exceeds threshold → Rate limit
Alibaba Cloud WAF Configuration:
# Alibaba Cloud WAF Rule Configuration
Rule Name: Block Common SQL Injection
Match Conditions:
- Field: URI
Logic: Contains
Value: "select|union|insert|delete|update"
Action: Block
Priority: 10
3.3 WAF Mode Selection
| Mode | Description | Use case |
|---|---|---|
| Detection mode | Log only, no blocking | Troubleshoot false positives |
| Block mode | Block attacks directly | Production |
| Challenge mode | Show CAPTCHA | Uncertain requests |
4. Bot Management
4.1 Bot Traffic Classification
Bot traffic can be good or bad:
| Bot type | Examples | Handling |
|---|---|---|
| Search engine bots | Googlebot, Bingbot | Allow |
| Monitoring bots | UptimeRobot, Pingdom | Allow |
| Crawler bots | Data scraping | Rate limit |
| Attack bots | Brute force, CC attacks | Block |
| AI training bots | GPTBot, ClaudeBot | Block as needed |
4.2 Bot Management Configuration
# Cloudflare Bot Management (Enterprise feature)
# Custom rule: Return CAPTCHA for crawler bots
if (cf.bot_management.score < 30) {
return 403;
}
# robots.txt control
User-agent: GPTBot
Disallow: /
4.3 Common Bot Handling Strategies
Search engine crawlers: Allow (but follow robots.txt)
AI training crawlers: Recommend blocking (robots.txt + firewall rules)
Price scraping crawlers: Rate limit (max 10 requests per minute)
Brute force bots: Direct block (IP blacklist)
5. SSL/TLS Security
SSL features provided by CDN:
| Feature | Description |
|---|---|
| Certificate Management | Auto-issuance and renewal |
| Full-site HTTPS | End-to-end encryption from user to CDN to origin |
| HSTS | Forces browsers to use HTTPS |
| Minimum TLS Version | Disables outdated TLS versions |
| Certificate Monitoring | Automatic expiration reminders |
Recommended Configuration:
# Cloudflare SSL/TLS Settings
SSL Mode: Full (strict)
Minimum TLS Version: 1.2
Always Use HTTPS: Enabled
HSTS: Enabled (max-age=31536000)
6. Security Best Practices
6.1 Hide Origin Server IP
One of the most important security features of CDN — hiding the origin's real IP:
- Ensure all traffic goes through CDN, never expose origin IP directly
- Only allow CDN node IPs to access origin
- Don't expose origin IP in DNS records (including subdomains)
- Don't leak origin info in HTTP response headers
6.2 IP Blacklist/Whitelist
# Only allow specific IPs to access admin backend
if (request.uri ~* "^/admin/") {
if (ip !in $admin_whitelist) {
return 403;
}
}
6.3 Geo-Restrictions
For businesses that don't need cross-border access, you can restrict access by geographic location:
# Only allow Chinese IPs to access
if (request.country != "CN") {
return 403;
}
7. Recommended CDN Security Solutions
Personal Blog / Small Website
Recommended Solution: Cloudflare Free
Security Capabilities: Basic DDoS protection + Free SSL + Rate limiting (via WAF rules)
Enterprise Website / E-commerce
Recommended Solution: Cloudflare Pro + WAF
Security Capabilities: Enhanced DDoS protection + Managed WAF + Custom rules
Finance / High-Value Business
Recommended Solution: Cloudflare Enterprise or Alibaba Cloud WAF + CDN
Security Capabilities: Premium DDoS protection + Custom WAF + Bot Management + SLA guarantee
8. Summary
CDN security protection offers the best return on investment in a website's security architecture. Implementing DDoS protection, WAF, and Bot management through a CDN can significantly enhance security without increasing server load. Even if your website has low traffic, it's recommended to use CDN security features — the free DDoS protection and SSL certificates alone are worth the configuration effort.