Skip to content

feat(waf): reference HAProxy + SPOE config for Coraza (M1-02) - #163

Merged
bihius merged 2 commits into
mainfrom
feat/issue-105-haproxy-reference-config
Apr 25, 2026
Merged

bihius merged 2 commits into
mainfrom
feat/issue-105-haproxy-reference-config

Conversation

@bihius

@bihius bihius commented Apr 25, 2026 •

Copy link
Copy Markdown
Owner

Summary

Adds the hand-written reference HAProxy configuration that M1-02 calls for, so HAProxy can consult the Coraza SPOA before forwarding requests. This file becomes the seed the M2 Jinja2 template generator (#110) must reproduce.

Refs #105. Full DoD ("benign request forwarded, SQLi blocked end-to-end") depends on #106 (CRS bundle), #107 (compose wiring), and #108 (smoke test).

Test plan

- add scaffold haproxy.cfg with single frontend, spoe filter
- add scaffold coraza.cfg with spoe-agent coraza-agent, timeouts config, spoe-message on frontend http request
- add configs/haproxy/README.md documenting request flow and SPOE variables
- remove obsolete deploy/docker scaffolds superseded by configs/haproxy/

Refs #105

Made-with: Cursor
Copilot AI review requested due to automatic review settings April 25, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a hand-written, reference HAProxy + SPOE configuration to integrate HAProxy with the Coraza SPOA (M1-02), intended to serve as the seed for the upcoming Jinja2 config generator in M2.

Changes:

  • Added configs/haproxy/haproxy.cfg reference HAProxy config with SPOE filter + vhost routing and deny-on-txn.coraza.action=deny.
  • Added configs/haproxy/coraza.cfg SPOE engine/message definition to send request metadata to Coraza SPOA.
  • Added configs/haproxy/README.md documenting request flow, SPOE variables/args, validation steps; removed obsolete deploy/docker/* scaffolding configs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
deploy/docker/haproxy/haproxy.cfg Deleted old HAProxy scaffold config (now superseded by configs/haproxy/).
deploy/docker/coraza/coraza.conf Deleted old Coraza scaffold config (now superseded by new config structure).
configs/haproxy/haproxy.cfg New reference HAProxy config: frontend, ACL, SPOE filter, deny logic, app + SPOA backends.
configs/haproxy/coraza.cfg New SPOE agent/message config for Coraza integration.
configs/haproxy/README.md New documentation for the reference config, flow, variables, validation, and issue links.

Comment thread configs/haproxy/README.md
Comment on lines +47 to +52
| Variable | Meaning |
|----------------------|--------------------------------------------------------|
| `txn.coraza.action` | Decision string (`deny` blocks; anything else allows) |
| `txn.coraza.score` | Anomaly score from the rule set, propagated as header |
| `txn.coraza.id` | Transaction id correlated with HAProxy's `unique-id` |

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot apply changes based on this feedback

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After reviewing the file, all three tables in configs/haproxy/README.md already use single | row starts — there are no || double-pipe prefixes in the file. The automated reviewer comment appears to have been a false positive. No changes are needed.

Comment thread configs/haproxy/README.md
Comment on lines +62 to +75
| Argument | HAProxy fetch | Notes |
|------------|------------------|----------------------------------------|
| `app` | `str(default)` | Which Coraza application bundle to use |
| `id` | `unique-id` | Same value as the `X-Request-ID` header|
| `src-ip` | `src` | Client IP |
| `src-port` | `src_port` | Client TCP port |
| `dst-ip` | `dst` | HAProxy bind IP |
| `dst-port` | `dst_port` | HAProxy bind port |
| `method` | `method` | HTTP method |
| `path` | `path` | Request path without query |
| `query` | `query` | Raw query string |
| `version` | `req.ver` | HTTP version |
| `headers` | `req.hdrs` | All request headers, framed for SPOE |
| `body` | `req.body` | Request body (subject to SPOA limits) |
Comment on lines +9 to +11
# This file is the hand-written seed that the M2 Jinja2 template
# generator will later reproduce from the policy database.

Comment thread configs/haproxy/haproxy.cfg Outdated
Comment on lines +34 to +39
# Sent once per HTTP request, before the backend selection. The
# argument names on the right hand side are HAProxy fetches; the
# names on the left hand side are what the Coraza SPOA expects.
spoe-message coraza-req
args app=str(default) id=unique-id src-ip=src src-port=src_port dst-ip=dst dst-port=dst_port method=method path=path query=query version=req.ver headers=req.hdrs body=req.body
event on-frontend-http-request
Comment thread configs/haproxy/README.md
Comment on lines +11 to +15
| File | Purpose |
|--------------|----------------------------------------------------------|
| `haproxy.cfg`| Frontend, vhost ACL, SPOE filter, backends |
| `coraza.cfg` | SPOE engine + message definition for the Coraza SPOA |
| `README.md` | This document |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@bihius
bihius merged commit 1964e81 into main Apr 25, 2026
3 checks passed
Copilot stopped work on behalf of bihius due to an error April 25, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants