# 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: # The host port is a variable, not a literal. Two CI jobs that each bring # up this file against one docker daemon otherwise fight over the same # published port and the same project's containers — one job's teardown is # another job's connection refused. Measured with a local Actions runner # (act 0.2.89), where the image job and the console job share a daemon: the # console gate died at its seeding curl with exit 7 while the image job's # compose smoke was tearing the same project down. On GitHub's hosted # runners each job gets its own machine, which is exactly why this never # showed up there. - "${EDGE_PORT:-8080}:8080" environment: OPENWAF_ADMIN_TOKEN: ${OPENWAF_ADMIN_TOKEN:?set OPENWAF_ADMIN_TOKEN before starting} # The second token (OPEN-62): it can read every operator surface and # change none of them. Empty means unset, which is the shipped default — # the level only exists when an operator gives it its own value. OPENWAF_READ_ONLY_TOKEN: ${OPENWAF_READ_ONLY_TOKEN:-} 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: