Rule engine
Regular expressions compiled by Go's RE2, so matching is linear-time with no catastrophic backtracking. Rules carry a score; a request is blocked once the total reaches the anomaly threshold.
Rule schema
Runs inside Caddy itself. No sidecar, no cloud service in the request path.
Build a Caddy binary with the module using xcaddy:
xcaddy build --with github.com/fabriziosalmi/caddy-waf
./caddy list-modules | grep waf # http.handlers.wafOr run the published container image, which needs no Go toolchain:
docker run --rm -p 8080:8080 ghcr.io/fabriziosalmi/caddy-waf:0.4.1The module is also selectable on the Caddy download page, and caddy add-package github.com/fabriziosalmi/caddy-waf works for a one-off install — though Caddy's maintainers have proposed moving that command out of core, so do not build a deployment around it (#138).
See Installation for every supported path.
:8080 {
route {
waf {
rule_file rules.json
ip_blacklist_file ip_blacklist.txt
dns_blacklist_file dns_blacklist.txt
anomaly_threshold 20
metrics_endpoint /waf_metrics
}
reverse_proxy localhost:3000
}
}A first-time reader is recommended to follow this sequence:
| Document | Topic |
|---|---|
| introduction.md | What the middleware does and where it sits in the request pipeline. |
| installation.md | Build with xcaddy, the install script, or from source. |
| add-package-guide.md | Installing with caddy add-package. |
| docker.md | Building and running the supplied Dockerfile / docker-compose.yml. |
| configuration.md | Caddyfile directives, JSON fields, request phases, blocking precedence. |
| rules.md | rules.json schema, target identifiers, regex semantics. |
| blacklists.md | IP and DNS blacklist file formats. |
| ratelimit.md | The rate_limit block and behaviour. |
| geoblocking.md | block_countries, whitelist_countries, block_asns, fallback. |
| dynamicupdates.md | File watchers, what each reload covers and what it does not. |
| metrics.md | The /waf_metrics JSON document. |
| prometheus.md | A small exporter that scrapes the JSON metrics for Prometheus. |
| caddy-waf-elk.md | Shipping the JSON log file to an ELK stack with Filebeat. |
| attacks.md | Attack categories targeted by the bundled rule sets. |
| testing.md | Running test.py against a live WAF. |
| caddytest.md | Traffic generator for benchmarks and rule validation. |
| scripts.md | The Python helpers under the project root. |
rules.json — the default rule set wired into the supplied Caddyfile.rules/ — modular rule files grouped by attack category. Each file is a JSON array of rules and can be referenced directly with one or more rule_file directives.Only the latest release receives security fixes. Published advisories are listed under Security → Advisories.
v0.3.3 and earlier are affected by GHSA-gfj3-cmff-q8wh, a high-severity unauthenticated denial of service. Fixed in v0.3.4.
To report a vulnerability, use private vulnerability reporting rather than a public issue.