Files
openwaf/docker-compose.yml
T
Pavlo Ratushnyi b6126c2fd2 Two rules that had only ever been proven inside a test process
`Server errors alert, they never ban` and `Observe mode records the decision and
blocks nothing` are the two claims that protect honest traffic from this WAF: a
bad deploy must not lock out the site's own visitors, and a dry run must be
judgeable before it is allowed to act. Both were proven in-process, against
`FakeUpstream`, in `EdgeBlockingTests`. Neither had ever been proven against the
image users actually run. And `GET /admin-api/alerts` appeared in **zero** gate
scripts — the operator-visible half of the alerting pillar had no gate at all,
which is how the console gate found its first bug: everything below the surface
looks fine while nothing reads it.

`deploy/upstream.conf` is nginx's own default plus one path that answers 502,
mounted read-only into the compose upstream. `scripts/compose-smoke.sh` grew two
sections, 28 → **35 assertions**:

    - server errors alert, and never ban
      a 502 reaches the client through the edge / four 502s did not ban the source
      that saw them / no engine ban written / a server_error_streak alert exists
    - Observe mode records the decision and blocks nothing
      five refusals still reach the upstream / no ban written / the dry run is
      visible as a candidate_ban alert

Numbers: host **35 passed, 0 failed**; the same script in the Linux rehearsal
(`docker:cli` against the host daemon) **35 passed, 0 failed**.

Two lessons about counting, both written into the script:

- The data volume survives `compose down`, so an absolute alert count asserts
  history rather than this run. Alerts are counted as a delta now.
- The alert is written *after* the response is, so a count read the instant the
  last request returns undercounts. The first version of the measurement line
  printed 1 where the settled number is 2. A number that is wrong by a race is
  worse than no number, so the count is taken after a pause.

The measurement itself is the finding: **4 requests past N=3 wrote 2 alert rows**
— one row per response past the threshold, not one per source. A real 5xx storm
therefore writes at request rate. Retention ages alerts out (`BanRetention`), so
they do not accumulate forever, but the write rate is a number an operator should
know before their upstream falls over.

Honest about the fixture: the 502 is nginx returning it directly, not an
application failing behind nginx. The edge's classifier sees a status code on a
socket, which is exactly what the rule is about; the fixture does not simulate a
crashed process, and nothing should read it as if it did.
2026-10-01 16:24:02 +02:00

46 lines
1.8 KiB
YAML

# The edge in front of an application it knows nothing about. That is the
# point: openwaf decides on what the upstream answered, so the upstream can be
# anything. `upstream` here is nginx purely so the compose file demonstrates a
# ban with nothing but curl.
#
# Before starting: set OPENWAF_ADMIN_TOKEN. Without it the admin API is closed
# (404), which is the safe default, not a misconfiguration.
services:
edge:
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
environment:
OPENWAF_ADMIN_TOKEN: ${OPENWAF_ADMIN_TOKEN:?set OPENWAF_ADMIN_TOKEN before starting}
OpenWaf__Policy__Mode: Enforce
OpenWaf__Policy__StreakThreshold: "10"
OpenWaf__Policy__StreakWindow: "00:05:00"
OpenWaf__Policy__BanDuration: "01:00:00"
# Only turn this on when the edge sits behind a proxy you control and
# whose address you have allowlisted. If X-Forwarded-For is
# attacker-controlled, every request gets a fresh source key and no
# streak ever matures.
OpenWaf__Policy__TrustProxyHeaders: "false"
ReverseProxy__Clusters__upstream__Destinations__upstream1__Address: "http://upstream:80/"
volumes:
- openwaf-data:/app/data
- openwaf-geoip:/app/geoip
depends_on:
- upstream
upstream:
image: nginx:alpine
restart: unless-stopped
# deploy/upstream.conf is nginx's own default plus one path that answers 502,
# so scripts/compose-smoke.sh can prove "server errors alert and never ban"
# against the deployed image instead of only against a fake upstream in a
# test. Remove this mount and the demo still works; that assertion fails.
volumes:
- ./deploy/upstream.conf:/etc/nginx/conf.d/default.conf:ro
volumes:
openwaf-data:
openwaf-geoip: