A Web Application Firewall (WAF) sits between your web applications and the internet, filtering malicious traffic before it reaches your servers. Self-hosted WAFs give you full control over security rules, logging, and blocking behavior without sending sensitive request data to cloud-based WaaS providers.
In this guide, we compare three leading self-hosted WAF solutions: ModSecurity, Coraza, and BunkerWeb. Each offers different approaches to web application protection, from the battle-tested ModSecurity engine to the modern Go-based Coraza and the all-in-one BunkerWeb platform.
What Is a Self-Hosted WAF?
A Web Application Firewall inspects HTTP/HTTPS traffic and applies security rules to block common attack patterns including SQL injection, cross-site scripting (XSS), path traversal, and remote code execution. Self-hosted WAFs run on your own infrastructure rather than as a cloud service.
Key benefits of self-hosted WAF solutions:
- Data privacy: Request and response data never leaves your network
- Custom rules: Write and deploy rules tailored to your specific applications
- No per-request pricing: Unlimited traffic without cloud WAF metering
- Low latency: Local processing avoids the round-trip delay of cloud WAFs
- Compliance: Meet data residency requirements by keeping inspection on-premises
ModSecurity vs Coraza vs BunkerWeb: Feature Comparison
| Feature | ModSecurity | Coraza | BunkerWeb |
|---|---|---|---|
| Language | C | Go | Python + Nginx |
| License | Apache 2.0 | Apache 2.0 | AGPL v3 |
| Stars | 10,000+ | 3,000+ | 3,000+ |
| Rule Engine | SecRules | SecRules (compatible) | Built-in + CRS |
| OWASP CRS Support | Native | Native | Native |
| Reverse Proxy Mode | Via Nginx/Apache | Via Caddy/Envoy | Built-in Nginx |
| Docker Support | Community images | Official images | Official images |
| Web UI | None | None | Built-in |
| Learning Mode | No | No | Yes (auto-rules) |
| GeoIP Blocking | Manual config | Via plugins | Built-in |
| Bot Detection | Manual rules | Manual rules | Built-in |
| Let us Encrypt | Manual | Manual | Built-in |
| Self-Hosted | Yes | Yes | Yes |
ModSecurity: The Industry Standard WAF
ModSecurity is the most widely deployed open-source WAF engine. Originally developed for Apache, ModSecurity v3 supports Nginx, Apache, and IIS through connector modules.
Key features:
- Mature rule engine with decades of real-world testing
- Full OWASP Core Rule Set (CRS) compatibility
- SecRules language for custom rule authoring
- Detailed audit logging for forensic analysis
- Supports Apache, Nginx, and IIS via connectors
- Extensive community knowledge base and tutorials
Docker Compose with Nginx + ModSecurity
| |
Core ModSecurity Configuration
| |
Coraza: Modern Go-Based WAF Engine
Coraza is a modern, enterprise-grade WAF written in Go. It implements the ModSecurity SecRules language for full compatibility while offering better performance and easier deployment through Go native integrations.
Key features:
- Full ModSecurity SecRules language compatibility
- Native OWASP CRS support
- Caddy, Envoy, and Traefik integration via plugins
- Better performance than ModSecurity v3 in benchmarks
- Memory-safe implementation in Go
- Designed for cloud-native and microservices architectures
Docker Compose with Caddy + Coraza
| |
Coraza Caddyfile Configuration
| |
BunkerWeb: All-in-One WAF Platform
BunkerWeb is a next-generation WAF built on Nginx with a focus on ease of use. It combines a reverse proxy, WAF engine, auto-learning mode, and a web-based management UI into a single package.
Key features:
- Built-in web UI for rule management and monitoring
- Auto-learning mode that generates rules from normal traffic
- Integrated Let us Encrypt certificate management
- Built-in bot detection and GeoIP blocking
- Docker Swarm and Kubernetes support
- Real-time monitoring dashboard
- One-command deployment
Docker Compose for BunkerWeb
| |
Choosing the Right WAF
Use ModSecurity when:
- You need the most battle-tested and widely documented WAF
- Your team has existing SecRules expertise
- You run Apache or Nginx and want mature connector modules
- You need extensive community support and tutorials
Use Coraza when:
- You want ModSecurity compatibility with better performance
- You use Caddy, Envoy, or Traefik as your reverse proxy
- You prefer memory-safe Go over C for security-critical components
- You are building cloud-native or microservices architectures
Use BunkerWeb when:
- You want an all-in-one solution with a web management UI
- You need auto-learning mode for rapid rule generation
- You want built-in TLS, bot detection, and GeoIP without extra configuration
- You prefer Docker label-based configuration over manual config files
Why Self-Host Your WAF?
Running a WAF on your own infrastructure gives you advantages that cloud WAFs cannot match:
Complete data privacy: HTTP requests often contain sensitive data including authentication tokens, personal information, and business secrets. Self-hosted WAFs inspect this traffic locally without transmitting it to third-party cloud providers.
Zero added latency: Cloud WAFs add network round-trip time as traffic routes through their data centers before reaching your servers. A self-hosted WAF processes requests on the same network, adding minimal latency.
Unlimited traffic capacity: Cloud WAF services charge per-request or bandwidth. Self-hosted WAFs handle unlimited traffic at the cost of your own compute resources, which is far cheaper at scale.
Custom rule deployment: Deploy application-specific WAF rules immediately without waiting for cloud provider approval or rule propagation delays. Test and iterate rules in your own environment.
Regulatory compliance: For industries with strict data residency requirements, keeping WAF inspection on-premises ensures request data never crosses jurisdictional boundaries.
For comprehensive server security, pair your WAF with self-hosted IDS/IPS tools for network-layer protection. Combine with container security scanning to catch vulnerabilities before deployment.
FAQ
What is the difference between ModSecurity and Coraza?
Coraza is a Go reimplementation of the ModSecurity engine that maintains full SecRules language compatibility while offering better performance and native integrations with modern proxies like Caddy and Envoy. ModSecurity is the original C-based engine with broader platform support.
Does BunkerWeb use ModSecurity internally?
Yes. BunkerWeb uses ModSecurity as its WAF engine but wraps it with a user-friendly interface, auto-learning capabilities, and additional features like bot detection and GeoIP blocking that ModSecurity does not include out of the box.
Can I migrate ModSecurity rules to Coraza?
Yes. Coraza implements the full ModSecurity SecRules language, so existing rule files are compatible. You may need to adjust connector-specific directives since Coraza uses different integration points.
What is OWASP CRS and do these tools support it?
The OWASP Core Rule Set is a collection of generic attack detection rules that provide protection against common web application attacks. All three tools support OWASP CRS natively, with ModSecurity and Coraza offering direct inclusion and BunkerWeb bundling it as a configurable option.
Is a self-hosted WAF enough for production security?
A WAF is one layer of defense. For production environments, combine it with network firewalls, container security scanning, TLS enforcement, and regular vulnerability assessments. See our container security guide for additional layers.
Does Bunker work with Docker Swarm and Kubernetes?
Yes. BunkerWeb supports Docker Swarm through its scheduler service and Kubernetes through its official Helm chart. Both deployments use the same label-based configuration approach.