How fabriziosalmi/caddy-waf works
Project type and purpose
• This is a Go-based middleware plugin for the Caddy web server, implementing a full-featured Web Application Firewall (WAF).
• It inspects HTTP traffic in multiple phases, applies regex rules, IP/DNS/TOR blacklists, GeoIP checks, rate limiting, anomaly scoring, dynamic config reloads, logging, metrics and a simple UI.
File structure
• Top-level Go code:
– handler.go, request.go, response.go: core HTTP handling
– config.go: parsing Caddyfile and JSON rule configuration
– blacklist.go, geoip.go, tor.go: IP, DNS, TOR blacklist services
– ratelimiter.go: per-IP rate limiting
– rules.go, helpers.go, types.go, logging.go, debug_waf.go: rule engine, utilities, logging, debugging
• Rules and data files:
– rules/*.json and sample_rules.json: built-in rule sets by attack type
– ip_blacklist.txt, dns_blacklist.txt, tor_blacklist.txt: raw blacklist sources
– GeoLite2-Country.mmdb external database (optional)
• Python scripts and utilities:
– get_* scripts to fetch or regenerate blacklists and rules from external sources
– caddytest.py, e2e.py, benchmark.py, debug_test_results.py, check_waf_config.py: testing, benchmarking, validation
• Configuration and deployment:
– Caddyfile, Dockerfile, install.sh, install_with_modules.sh, Caddy workflows in .github
– docs/ folder with Markdown files describing all features, metrics, prometheus, ELK integration
• Static UI:
– ui/index.html: minimal in-browser interface for simple rule overview
README for additional insights
• Confirms middleware integration into Caddy request pipeline
• Lists all protection features: regex filtering, blacklists, geo-blocking, rate limiting, anomaly scoring, dynamic updates, observability (Prometheus/ELK), custom responses, metrics endpoint, simple UI
• Shows example Caddyfile integration and quick installation steps
• Points to docs directory for deeper technical references