Skip to content
Caddy and Coraza WAF integration with OWASP CRS
SecurityWAFDockerSupply Chain SecurityActive

Caddy and Coraza WAF Integration

Caddy v2.11.7 with Coraza WAF v2.6.2 and OWASP CRS v4.30: Cosign-signed images, Trivy scanning, SLSA provenance, and non-root execution for edge proxy security.

1. Problem

Self-hosted infrastructure requires edge security against SQL injection, cross-site scripting, path traversal, and command injection. Managed WAF solutions introduce vendor lock-in and per-request pricing that scales unpredictably with traffic volume. These platforms enforce opaque rule engines, reducing control over the security stack for bare metal, VPS, and on-premises deployments.

2. Context

The implementation uses Caddy v2.11.7 as the reverse proxy with Coraza WAF v2.6.2 executing the OWASP Core Rule Set v4.30.0. Edge containers must run as non-root (UID 1337) per the CIS Docker Benchmark to restrict container escape blast radius. Deployment pipelines require deterministic supply chain verification: cryptographically signed images, vulnerability scanning, and dependency integrity checks before runtime execution.

The project reached v3.6.4 in the Developmi organization, adopting Cosign keyless signing, SBOM attestation, SLSA build provenance, and native integration with the caddy-waf-ui sidecar management interface.

3. Trade-offs

Option Upfront Cost Recurring Cost Vendor Lock-in Operational Overhead
Managed Cloud WAF Zero Per-request billing High Low
Unprotected Proxy Zero Zero None Critical security risk
Caddy + Coraza WAF Compute only Zero None Moderate (rule tuning)

Managed WAFs reduce initial configuration effort but create dependency on provider-specific rule engines and pricing models. An unprotected proxy eliminates cost and lock-in at the expense of accepting all attack surface. The Caddy and Coraza combination requires upfront tuning but removes variable costs and preserves full control over the security rule set.

4. Decision

The project ships a custom container build integrating Caddy with Coraza WAF and supplementary plugins:

  • Caddy v2.11.7 - updated Caddy distribution with upstream security fixes
  • Coraza WAF v2.6.2 - upgraded WAF engine with dependency CVE mitigations
  • OWASP CRS v4.30.0 - 290+ protection rules covering the OWASP Top 10
  • caddy-ratelimit - pinned by commit SHA for DDoS protection
  • caddy-dns/cloudflare v0.2.4 - ACME DNS-01 challenge support

Execution Privileges

The container executes as an unprivileged user (UID 1337) with dropped capabilities, read-only root filesystem, and no-new-privileges security policy.

USER caddy:caddy
WORKDIR /srv

Supply Chain Verification

OWASP CRS is downloaded and verified via SHA256 checksums at build time. Container images are signed with Cosign keyless signing, include SBOM attestations, and are verified by SLSA build provenance. Trivy scans for CRITICAL and HIGH vulnerabilities before every release.

curl -sL https://github.com/coreruleset/coreruleset/archive/refs/tags/v4.30.0.tar.gz \
  | sha256sum --check checksums.txt

Edge Configuration & Runtime Management

The WAF defaults to DetectionOnly mode to establish a traffic baseline and prevent false positives during initial deployment. In production, sites can be dynamically managed via caddy-waf-ui using per-slug configuration overlays.

{
    email admin@example.com
    order coraza_waf first
}

(waf) {
    coraza_waf {
        directives `
            Include /etc/caddy/coraza.conf
            Include /etc/caddy/owasp-crs/crs-setup.conf
            Include /etc/caddy/owasp-crs/rules/*.conf

            SecRuleEngine DetectionOnly
            SecAuditEngine RelevantOnly
            SecAuditLog /dev/stdout
            SecAuditLogFormat JSON
        `
    }
}

Architecture supports linux/amd64 and linux/arm64.

5. Result

The container provides a functional WAF with automatic HTTPS provisioning via Let’s Encrypt, Coraza rule evaluation, and structured audit logging.

Verified Image

docker pull ghcr.io/developmi/caddy-waf:v3.6.4

Signature Verification

cosign verify \
  --certificate-identity "https://github.com/developmi/caddy-waf/.github/workflows/docker-build-scan-sign.yml@refs/heads/main" \
  --certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
  ghcr.io/developmi/caddy-waf@sha256:<digest>

Observability

WAF interventions output JSON to stdout, compatible with Grafana Loki, Elasticsearch, or any SIEM that accepts structured log ingestion.

{
  "transaction": {
    "timestamp": "2026-02-17T10:30:15Z",
    "client_ip": "203.0.113.45",
    "request_uri": "/admin?id=1' OR '1'='1",
    "matched_rules": ["942100"],
    "action": "deny"
  }
}

Deployment Options

Docker Compose for containerized environments and a systemd service file for bare metal deployments are included in the repository. Image size is approximately 45 MB compressed for both architectures.

References

Have a specific infrastructure problem? Let's talk.

Start a Conversation