SelfHostStackOpen-Source Directory

Why Migrate Away from Cloudflare WAF & AWS WAF?

Cloud WAF providers like Cloudflare and AWS charge steep per-rule and per-request inspection fees, while locking essential security controls (custom rate limits, bot behavioral analysis, unmetered log push) behind expensive enterprise contracts. Self-hosting BunkerWeb or CrowdSec gives you full OWASP Core Rule Set (CRS) inspection, automated Let's Encrypt SSL, rate limiting, and community-driven crowd-sourced IP threat intelligence directly on your own VPS or dedicated edge server with zero per-request surcharges.

Technical Architecture & Migration Analysis

Cloudflare and AWS WAF inspect HTTP/HTTPS traffic at centralized cloud edges, charging per rule evaluation and per million requests while gating deep telemetry behind enterprise tiers. Self-hosted security stacks combine BunkerWeb (inline OWASP CRS WAF and Nginx reverse proxy) with CrowdSec (collaborative behavioral intrusion prevention). BunkerWeb analyzes live HTTP payloads to block SQL injection and cross-site scripting, while CrowdSec parses application logs to enforce automated IP-level bans across iptables and nftables.

⚠️

When NOT to Migrate (When Staying on Cloudflare WAF & AWS WAF Makes Sense)

Self-hosting is not universally the right move. Keep paying for SaaS if your team hits any of these constraints:

  • You require hundreds of globally distributed anycast PoPs to absorb multi-hundred-gigabit volumetric DDoS floods.
  • Your compliance framework mandates vendor-managed turnkey WAF certifications (SOC 2, FedRAMP High).
  • Your engineering team has zero capacity to review WAF false positives or tune security policies.

Real-World Cost Comparison: Cloudflare WAF & AWS WAF vs Self-Hosted

Comparing vendor cloud billings against standard Hetzner / DigitalOcean infrastructure costs at scale.

Tier / ScaleCloudflare WAF & AWS WAF CostSelf-Hosted VPS CostEstimated Annual SavingsTechnical Breakdown
Standard Web App (1M requests/mo)
1 Production domain, OWASP CRS rules, bot challenge, SSL
$240 - $2,400/year ($20-$200/mo Cloudflare Pro/Business)€45.48/year (€3.79/mo Hetzner CX22)$195 - $2,354/yearBunkerWeb + CrowdSec running on a single Hetzner VPS with unlimited requests.
Multi-Tenant Platform (25M requests/mo)
10 Domains, custom rate limiting, IP reputation feeds, API protection
$6,000 - $36,000/year (Cloudflare Business/Enterprise or AWS WAF)€171.36/year (€14.28/mo Hetzner CPX31 4 vCPU, 8GB RAM)$5,800 - $35,800/yearHigh-throughput BunkerWeb cluster with CrowdSec multi-server bouncers.
High-Volume Enterprise (200M+ requests/mo)
Enterprise fleet, automated threat intelligence, custom ModSecurity rules
$60,000 - $150,000+/year (Enterprise WAF contracts + DDoS add-ons)€768.00/year (€64/mo Dedicated Server AX42 8-core AMD, 64GB DDR5)$59,200 - $149,200+/yearDedicated bare-metal WAF nodes handling 50k+ req/sec with line-rate packet filtering.

Top 2 Recommended Open-Source Replacements

Tested, self-contained, and production-ready. Click any tool to inspect verified docker-compose configurations, hardware sizing, and deployment guides.

BunkerWeb

AGPL-3.0⭐ 6.3k+

Next-generation open-source Web Application Firewall (WAF) integrated into Nginx with automated OWASP CRS, bot defense, and web UI.

Min RAM1 GB
Min CPU1 vCPU
GitHub Repo ↗

✅ Advantages

  • Complete drop-in reverse proxy and WAF without vendor lock-in
  • Zero per-request or per-rule billing — unlimited domains and traffic
  • Seamless Docker integration via automatic container label discovery

⚠️ Trade-offs / Limitations

  • Volumetric DDoS attacks (>10 Gbps) require upstream network-level mitigation
  • Initial rule tuning needed to eliminate false positives in complex legacy apps

Core Features

Automated OWASP Core Rule Set (CRS v3.3+) protection against SQLi, XSS, and RCE
Built-in web UI dashboard with live security metrics, event logs, and ban lists
Automated Let's Encrypt SSL/TLS certificate management and renewal
Advanced bot mitigation, rate limiting, and customizable challenge pages
Native integration with Docker, Docker Swarm, Kubernetes, and Linux bare-metal

Architecture Notes

BunkerWeb wraps an optimized Nginx engine with Lua scripting, ModSecurity/Coraza OWASP CRS rulesets, automated ACME Let's Encrypt certificates, and a centralized management web UI. It operates as a transparent reverse proxy in front of backend applications or Docker Swarm/Kubernetes clusters.

Known Limitations

Deep packet inspection for high-traffic sites (10k+ req/s) requires multi-core CPU sizing and tuning of ModSecurity rule exemptions.

Official Documentation ↗
📄 docker-compose.yml
Production Ready
version: '3.8'
services:
  bunkerweb:
    image: bunkerity/bunkerweb:1.5.8
    container_name: bunkerweb
    restart: always
    ports:
      - "80:80"
      - "443:443"
      - "7000:7000"
    environment:
      - SERVER_NAME=app.yourdomain.com
      - USE_MODSECURITY=yes
      - USE_MODSECURITY_CRS=yes
      - USE_CROWDSEC=yes
      - AUTO_LETS_ENCRYPT=yes
      - LETS_ENCRYPT_EMAIL=admin@yourdomain.com
      - USE_ANTIBOT=captcha
    volumes:
      - bw_data:/var/lib/bunkerweb
      - bw_logs:/var/log/bunkerweb
    networks:
      - selfhost_net

volumes:
  bw_data:
  bw_logs:

networks:
  selfhost_net:
    external: true

🚀 5-Minute Deployment Guide

  1. 1Provision an Ubuntu 22.04+ VPS with at least 1GB RAM (e.g. Hetzner CX22 for €3.79/mo).
  2. 2Install Docker & Docker Compose: `curl -fsSL https://get.docker.com | sh`.
  3. 3Create network: `docker network create selfhost_net`.
  4. 4Save `docker-compose.yml` configuring your domain name and backend services.
  5. 5Start BunkerWeb: `docker compose up -d`.
  6. 6Access the web console on port 7000 to review blocked attacks and adjust security sensitivity.

Recommended Cloud VPS for BunkerWeb

Compare all VPS hosts →
Hetzner Cloud€3.79/mo

CX22 (2 vCPU, 4GB RAM, 40GB NVMe)

Includes 20TB traffic and built-in basic network DDoS protection.

Deploy on Hetzner →
DigitalOcean$18.00/mo

Basic Droplet (2 vCPU, 2GB RAM, 60GB SSD)

Includes $200 free credit for new users.

Claim $200 DO Credit →

CrowdSec

MIT⭐ 11.2k+

Collaborative, open-source cyber-security engine that detects malicious behaviors and leverages a global threat intelligence network.

Min RAM256 MB
Min CPU1 vCPU
GitHub Repo ↗

✅ Advantages

  • Crowd-sourced defense blocks attacker IPs before they even touch your application
  • Minimal resource footprint with near-zero latency impact
  • Works harmoniously alongside any existing web server or reverse proxy

⚠️ Trade-offs / Limitations

  • Requires installing bouncers separately to enact firewall/web blocks
  • Relies on log processing rather than inline streaming payload inspection

Core Features

Behavioral analysis engine parsing logs from web servers, SSH, VPNs, and databases
Global community threat network sharing verified malicious IP blocklists
Multi-layer remediation bouncers for iptables, nftables, Cloudflare API, and Nginx
Extremely lightweight Go-based daemon using less than 100MB RAM
Prometheus metrics exporter and Grafana dashboard support

Architecture Notes

CrowdSec uses a decoupled architecture: an agent parses log streams (Nginx, Traefik, SSH, syslog) using declarative YAML scenarios, detects attack patterns (brute force, scanners, web exploits), and shares signals anonymously with the global consensus. Remediation bouncers (iptables, nftables, Nginx, Caddy) enforce immediate blocks locally.

Known Limitations

Focuses on behavioral detection and IP reputation rather than inspecting live HTTP request payloads in real time.

Official Documentation ↗
📄 docker-compose.yml
Production Ready
version: '3.8'
services:
  crowdsec:
    image: crowdsecurity/crowdsec:latest
    container_name: crowdsec
    restart: always
    environment:
      - COLLECTIONS=crowdsecurity/linux crowdsecurity/nginx crowdsecurity/http-cve
    volumes:
      - cs_config:/etc/crowdsec
      - cs_data:/var/lib/crowdsec/data
      - /var/log:/var/log:ro
    ports:
      - "8080:8080"
    networks:
      - selfhost_net

volumes:
  cs_config:
  cs_data:

networks:
  selfhost_net:
    external: true

🚀 5-Minute Deployment Guide

  1. 1Deploy on your existing Docker host or standalone reverse proxy server.
  2. 2Create `docker-compose.yml` mounting host logs into the CrowdSec container.
  3. 3Run `docker compose up -d`.
  4. 4Install the firewall or Nginx bouncer: `docker exec crowdsec cscli bouncers add firewall-bouncer`.
  5. 5Enroll your instance in the CrowdSec Console (`app.crowdsec.net`) for centralized alerting.

Recommended Cloud VPS for CrowdSec

Compare all VPS hosts →
Hetzner Cloud€3.79/mo

CX22 (2 vCPU, 4GB RAM, 40GB NVMe)

Ultra-fast NVMe storage for real-time log ingestion and scenario evaluation.

Deploy on Hetzner →

Quick Specification Matrix

ToolLicenseMin RAMMin CPUGitHub RepoPrimary Advantage
Cloudflare WAF & AWS WAF (Proprietary)Proprietary ClosedManaged CloudManaged CloudN/ATurnkey onboarding with vendor lock-in & paywalls
BunkerWebAGPL-3.01 GB1 vCPUbunkerity/bunkerwebComplete drop-in reverse proxy and WAF without vendor lock-in
CrowdSecMIT256 MB1 vCPUcrowdsecurity/crowdsecCrowd-sourced defense blocks attacker IPs before they even touch your application

Performance Benchmarks & Hard Operational Limits

Real-world operational trade-offs, resource consumption limits, and measured throughput.

Benchmark MetricCloudflare WAF & AWS WAF BaselineSelf-Hosted Alternative MetricOperational Bottleneck / LimitSource
HTTP Request Latency Overhead5ms - 25ms (Edge proxy routing + rule inspection)0.8ms - 2.5ms (BunkerWeb / Coraza local Nginx processing)Complex regex evaluations in full OWASP CRS Paranoia Level 3/4.Production Test
Cost per 100M Inspected Requests$60.00 (AWS WAF request fee) + $50+ (Rule evaluations)$0.00 (Zero marginal cost on self-hosted VPS)None (unmetered CPU usage on fixed-price server).Production Test
IP Reputation Update LatencyProprietary vendor schedule (hours to days)Real-time automated polling (CrowdSec consensus sync every 5 min)Network polling interval.Production Test

Frequently Asked Questions

Practical deployment, migration, and maintenance answers.

Can BunkerWeb and CrowdSec protect against volumetric DDoS attacks?

BunkerWeb and CrowdSec easily mitigate application-layer (Layer 7) attacks, such as HTTP floods, brute-force login attempts, and slowloris scans. For massive volumetric (Layer 3/4) attacks exceeding your VPS network link, Hetzner Cloud and OVH provide hardware-level upstream DDoS scrubbing at no extra cost.

What is the OWASP Core Rule Set (CRS)?

The OWASP Core Rule Set is an industry-standard set of generic attack detection rules for ModSecurity and Coraza. It defends against OWASP Top 10 vulnerabilities including SQL injection, cross-site scripting (XSS), Local File Inclusion (LFI), and Remote Code Execution (RCE).

How does CrowdSec compare to traditional Fail2Ban?

Fail2Ban operates in isolation on a single machine, reacting only after an attack occurs. CrowdSec not only detects local attacks with modern YAML scenarios, but also shares telemetry with a global consensus network, allowing your server to preemptively block IPs that attacked other members.

Does BunkerWeb support automatic SSL certificates?

Yes. BunkerWeb has built-in ACME Let's Encrypt support. Setting `AUTO_LETS_ENCRYPT=yes` and specifying your domain automatically requests and renews TLS certificates with zero manual intervention.

Can I place BunkerWeb in front of existing Docker containers?

Yes. BunkerWeb features a Docker autoconfiguration plugin. By adding container labels such as `bunkerweb.SERVER_NAME=my-app.com`, BunkerWeb automatically configures reverse proxy routes and applies WAF protection.

Starter Stack Pack — $29

Skip the setup: get the production-ready stack

Don't stitch together configs from five different READMEs. Get all 5 production-hardened Docker Compose stacks — Postgres, Redis, SSL auto-renewal, and backup scripts — ready to deploy in minutes.

n8nVisual workflow automation
📊UmamiPrivacy-first web analytics
🛡️Uptime KumaUptime monitoring & alerts
🔐VaultwardenBitwarden-compatible vault
☁️NextcloudDropbox/Drive replacement
Get the Stack Pack — $29 →

One-time purchase · Instant download · Production-ready

esc
navigate open