How to Replace Cloudflare WAF with a Self-Hosted Alternative

1 1 34
calendar_todayschedule1 min read

If you're paying for Cloudflare Pro or Business just for the WAF, or you're on the free tier and want actual protection, here's how to migrate to a self-hosted solution.

Step 1: Figure Out Why You're Switching

Reason What SafeLine Does Instead
Free tier detection too weak (10.7%) Community Edition: 71.65% at $0
Don't want to pay $20-200/month Community Edition is completely free
Data privacy Traffic stays on your server
Need more than 5 custom rules Unlimited custom rules with regex
Want per-route bot control Bot protection configurable per route

Step 2: Deploy SafeLine

bash -c "$(curl -fsSLk https://waf.chaitin.com/release/latest/manager.sh)" -- --en

Dashboard at https://<your-server-ip>:9443. Takes about 3 minutes.

Step 3: Route Traffic Through SafeLine

Internet -> Nginx/Caddy (443) -> SafeLine (port 5080) -> Your App (port 3000)

Or let SafeLine be the primary reverse proxy.

Step 4: Add Your Sites

In the SafeLine dashboard, add each domain with its backend IP and port. Protection starts immediately.

Step 5: Recreate Your Cloudflare Rules

Cloudflare Rule SafeLine Equivalent
IP block IP blacklist in dashboard
Rate limit (1 rule) Unlimited rate limit rules
Country block (Enterprise) GeoIP blocking — free
Custom rules (5 max) Unlimited rules, full regex
Bot Fight Mode (global only) Bot protection per route

Step 6: DNS Cutover

Switch Cloudflare from orange-cloud to grey-cloud (DNS only) if you want to remove the proxy entirely.

Step 7: Keep Cloudflare for CDN/DDoS

User -> Cloudflare DNS/CDN -> SafeLine WAF -> Your App

FAQ

Will my site go down during the switch?

No. Run both during migration, then cut over.

Do I need to change DNS?

Only to remove Cloudflare's proxy. Keep it for DNS/CDN.

What about SSL?

SafeLine integrates with Let's Encrypt. Or keep SSL at your existing proxy.


Try SafeLine yourself: Live Demo | Website | Deploy Guide | Discord Community | More from CyberServal | LinkedIn

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

Comparison: Universal Import vs. Plaid/Yodlee

Pocket Portfolio - Mar 12

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

SafeLine WAF: A Self-Hosted Alternative to Cloudflare You Can Run Yourself

Lia - Sep 14

How to Deploy a Self-Hosted WAF Alternative to Cloudflare

Lia - Sep 15
chevron_left
1k Points36 Badges
38Posts
0Comments
1Connections
Homelab operator. Security tools. Self-hosted everything. Open source.

Related Jobs

View all jobs →

Commenters (This Week)

5 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!