Cloudflare Integration
Automatically block malicious IPs using Cloudflare’s Web Application Firewall.
Prerequisites
Section titled “Prerequisites”- A Cloudflare account
- Your website proxied through Cloudflare
- An API token with appropriate permissions
Creating a Cloudflare API Token
Section titled “Creating a Cloudflare API Token”-
Log into Cloudflare Dashboard
-
Go to My Profile → API Tokens
-
Click Create Token
-
Use Custom Token with these permissions:
Resource Permission Zone > Firewall Services Edit Zone > Zone Settings Read Zone > Zone Read -
Copy the generated token (shown only once)
Setting Up the Integration
Section titled “Setting Up the Integration”-
Go to Integrations → Cloudflare
-
Click Add Cloudflare Integration
-
Enter your credentials:
Field Description API Token Your Cloudflare API token Account ID Your Cloudflare account ID Zone ID The zone (domain) to protect Zone Name Domain name (e.g., yoursite.com) -
Click Connect
-
WebDecoy verifies the connection
Finding Your Account ID and Zone ID
Section titled “Finding Your Account ID and Zone ID”Account ID:
- Go to any domain in Cloudflare dashboard
- Look in the right sidebar under “API”
- Copy the “Account ID”
Zone ID:
- Go to the specific domain
- Look in the right sidebar under “API”
- Copy the “Zone ID”
Creating Blocking Rules
Section titled “Creating Blocking Rules”After connecting Cloudflare, set up automatic blocking:
-
Go to Integrations → Cloudflare → Rules
-
Click Add Rule
-
Configure the rule:
Setting Description Rule Type Block All or Block by Score Decoy Which decoy triggers the rule Score Threshold Minimum score to trigger (if by score) Block Duration How long to block (hours) -
Click Create Rule
Rule Types
Section titled “Rule Types”Block All:
- Blocks any IP that triggers the selected decoy
- Best for honeypots that should never be accessed
Block by Score:
- Only blocks IPs with threat score above threshold
- Recommended for most use cases
- Reduces false positives
Recommended Settings
Section titled “Recommended Settings”| Scenario | Score Threshold | Block Duration |
|---|---|---|
| High security | 50+ | 72 hours |
| Standard protection | 70+ | 24 hours |
| Conservative | 85+ | 12 hours |
How Blocking Works
Section titled “How Blocking Works”Detection Created (score: 85) │ ▼Cloudflare Rule Evaluated │ ├── Score >= Threshold? → Yes │ ▼Create Firewall Rule in Cloudflare │ ├── Action: Block ├── IP: 192.168.1.100 └── Expires: 24 hours │ ▼IP Blocked at Cloudflare EdgeManaging Blocked IPs
Section titled “Managing Blocked IPs”Viewing Blocked IPs
Section titled “Viewing Blocked IPs”- Go to Integrations → Cloudflare
- Click View Blocked IPs
- See list of currently blocked IPs with:
- IP address
- Block reason (detection ID)
- Expiration time
- Manual unblock option
Unblocking an IP
Section titled “Unblocking an IP”- Find the IP in the blocked list
- Click Unblock
- Confirm the action
- IP is immediately removed from Cloudflare firewall
Best Practices
Section titled “Best Practices”- ✅ Use a dedicated API token (not global API key)
- ✅ Start with high score threshold (75+) and adjust down
- ✅ Set reasonable block durations (24h is a good default)
- ✅ Test with a known IP before production use
- ✅ Monitor blocked IP list for false positives
Don’ts
Section titled “Don’ts”- ❌ Use your global Cloudflare API key
- ❌ Set threshold too low initially (causes false positives)
- ❌ Set block duration to “forever” (IPs change hands)
- ❌ Block without monitoring results
Troubleshooting
Section titled “Troubleshooting””Invalid API Token” Error
Section titled “”Invalid API Token” Error”- Verify token was copied correctly (no extra spaces)
- Check token hasn’t expired
- Ensure token has required permissions
- Try creating a new token
”Zone Not Found” Error
Section titled “”Zone Not Found” Error”- Verify Zone ID is correct
- Ensure token has access to that zone
- Check zone is active in Cloudflare
IPs Not Being Blocked
Section titled “IPs Not Being Blocked”- Verify integration is connected (green status)
- Check rule is enabled
- Verify detection score meets threshold
- Check Cloudflare firewall rules directly
Blocks Not Expiring
Section titled “Blocks Not Expiring”- Check block duration setting
- Note: Cloudflare may cache rules briefly
- Blocks should auto-expire based on duration