<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Coraza | A DevOps Blog</title><link>https://blog.bsdserver.nl/tag/coraza/</link><description>Hands-on DevOps and homelab content: Kubernetes clusters, self-hosted services, CI/CD pipelines and infrastructure as code, by Patrick de Ruiter of We Build Your Cloud.</description><language>en</language><image><url>https://blog.bsdserver.nl/images/app-icon.svg</url><title>A DevOps Blog</title><link>https://blog.bsdserver.nl/</link></image><lastBuildDate>Wed, 18 Nov 2026 09:00:00 +0100</lastBuildDate><atom:link href="https://blog.bsdserver.nl/tag/coraza/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title>Securing HAProxy with Coraza-SPOA: A Step-by-Step Guide</title><link>https://blog.bsdserver.nl/securing-haproxy-with-coraza-spoa-a-step-by-step-guide/</link><guid isPermaLink="false">693b50e879eb54000160a470</guid><dc:creator>Patrick de Ruiter</dc:creator><pubDate>Thu, 11 Dec 2025 23:16:56 +0000</pubDate><description>Coraza-SPOA offers a powerful way to add Web Application Firewall (WAF) capabilities to HAProxy, enhancing security for your web applications.</description><category>HAProxy</category><category>Security</category><category>WAF</category><category>Coraza</category><media:content url="https://blog.bsdserver.nl/content/images/2026/01/haproxy-coraza-waf.png" medium="image"/><content:encoded><![CDATA[<p>Coraza-SPOA offers a powerful way to add Web Application Firewall (WAF) capabilities to HAProxy. HAProxy routes and balances requests but does not look for SQL injection, XSS or path traversal in them; a WAF does.</p>
<p>This guide compiles Coraza-SPOA, loads the OWASP Core Rule Set, runs it as a systemd service, and connects HAProxy to it so that malicious requests get a 403 before they reach your application.</p>
<h2 id="why-coraza-spoa">Why Coraza-SPOA? <a class="anchor" data-pagefind-ignore href="#why-coraza-spoa" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>OWASP Core Rule Set</strong>: a maintained, widely used rule set against common web attacks</li>
<li><strong>ModSecurity-compatible rules</strong>: Coraza reads the SecLang rule language</li>
<li><strong>Separate process</strong>: the WAF runs outside HAProxy; HAProxy only asks for a verdict</li>
<li><strong>Open source</strong>: no commercial HAProxy edition needed</li>
</ul>
<h3 id="when-to-use-it">When to use it <a class="anchor" data-pagefind-ignore href="#when-to-use-it" aria-label="Link to this section">#</a></h3>
<ul>
<li><strong>Use it</strong> in front of web applications you cannot fully trust or patch quickly: CMSs, legacy apps, third-party software.</li>
<li><strong>Skip it</strong> for pure APIs with strict input validation, or traffic that is not HTTP. Every request takes an extra round trip to the agent, and the CRS needs tuning against false positives.</li>
</ul>
<h2 id="architecture-overview">Architecture Overview <a class="anchor" data-pagefind-ignore href="#architecture-overview" aria-label="Link to this section">#</a></h2>
<table>
	<thead>
			<tr>
					<th>Component</th>
					<th>Runs on</th>
					<th>Job</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>HAProxy</td>
					<td>Load balancer</td>
					<td>Receives requests; the SPOE filter sends each one to the agent and acts on the verdict.</td>
			</tr>
			<tr>
					<td>Coraza-SPOA</td>
					<td>Same host, <code>127.0.0.1:9000</code></td>
					<td>Evaluates the request against the rules and returns an action.</td>
			</tr>
			<tr>
					<td>Core Rule Set</td>
					<td><code>/etc/coraza-spoa/rules/</code></td>
					<td>The attack-detection rules Coraza loads.</td>
			</tr>
			<tr>
					<td>Backend</td>
					<td>App servers</td>
					<td>Only receives requests Coraza allowed. Here: a static test response.</td>
			</tr>
	</tbody>
</table>
<p>The flow: request arrives → SPOE sends method, path, headers and body to Coraza-SPOA → Coraza runs the rules → HAProxy reads <code>txn.coraza.action</code> → <code>deny</code> gives a 403, otherwise the request goes to the backend.</p>
<h2 id="step-1-clone-and-compile-coraza-spoa">Step 1: Clone and Compile Coraza-SPOA <a class="anchor" data-pagefind-ignore href="#step-1-clone-and-compile-coraza-spoa" aria-label="Link to this section">#</a></h2>
<p>There are no packages, so you build the binary from source. Make sure you have Go installed before proceeding. The project builds with <a href="https://magefile.org/" rel="noopener">Mage</a> through <code>go run</code>, so nothing else needs to be installed.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Clone the Coraza-SPOA repo</span>
</span></span><span class="line"><span class="cl">git clone https://github.com/corazawaf/coraza-spoa.git
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Change into the directory and compile the binary (needs Go 1.25+;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># the result is build/coraza-spoa)</span>
</span></span><span class="line"><span class="cl"><span class="nb">cd</span> coraza-spoa
</span></span><span class="line"><span class="cl">go run mage.go build
</span></span></code></pre></div><h2 id="step-2-install-the-binary-and-set-permissions">Step 2: Install the Binary and Set Permissions <a class="anchor" data-pagefind-ignore href="#step-2-install-the-binary-and-set-permissions" aria-label="Link to this section">#</a></h2>
<p>Copy the binary to the path the bundled systemd unit expects, owned by root so the service user cannot replace it.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Place the binary in /usr/bin (the path contrib/coraza-spoa.service starts;</span>
</span></span><span class="line"><span class="cl"><span class="c1"># that unit also makes /usr/local inaccessible)</span>
</span></span><span class="line"><span class="cl">cp -p build/coraza-spoa /usr/bin/coraza-spoa
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Set ownership and permissions</span>
</span></span><span class="line"><span class="cl">chown root:root /usr/bin/coraza-spoa
</span></span><span class="line"><span class="cl">chmod <span class="m">755</span> /usr/bin/coraza-spoa
</span></span></code></pre></div><h2 id="step-3-create-directory-structure-for-logs-and-configuration">Step 3: Create Directory Structure for Logs and Configuration <a class="anchor" data-pagefind-ignore href="#step-3-create-directory-structure-for-logs-and-configuration" aria-label="Link to this section">#</a></h2>
<p>Coraza-SPOA reads its configuration from <code>/etc/coraza-spoa</code> and writes logs to <code>/var/log/coraza-spoa</code>.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Create directories</span>
</span></span><span class="line"><span class="cl">mkdir -p /etc/coraza-spoa
</span></span><span class="line"><span class="cl">mkdir -p /var/log/coraza-spoa/audit
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Create necessary log files</span>
</span></span><span class="line"><span class="cl">touch /var/log/coraza-spoa/server.log
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Repeat for all required log files</span>
</span></span><span class="line"><span class="cl"><span class="k">for</span> logfile in error.log debug.log audit/audit.log<span class="p">;</span> <span class="k">do</span>
</span></span><span class="line"><span class="cl">    touch /var/log/coraza-spoa/<span class="nv">$logfile</span>
</span></span><span class="line"><span class="cl"><span class="k">done</span>
</span></span></code></pre></div><h2 id="step-4-add-user-and-set-permissions">Step 4: Add User and Set Permissions <a class="anchor" data-pagefind-ignore href="#step-4-add-user-and-set-permissions" aria-label="Link to this section">#</a></h2>
<p>For security, Coraza-SPOA runs under its own user: a system account without a home directory or password, so a compromise of the WAF does not give a login.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Add a system group and user</span>
</span></span><span class="line"><span class="cl">addgroup --quiet --system coraza-spoa
</span></span><span class="line"><span class="cl">adduser --quiet --system --ingroup coraza-spoa --no-create-home --home /nonexistent --disabled-password coraza-spoa
</span></span></code></pre></div><p>There is no need to <code>chown</code> the log directory. The systemd unit from Step 7 has <code>LogsDirectory=coraza-spoa</code>, so every time the service starts, systemd makes <code>/var/log/coraza-spoa</code> and the files in it owned by <code>coraza-spoa:coraza-spoa</code> with mode 0755. A different owner or group set by hand would be undone at the next start.</p>
<h2 id="step-5-configure-coraza-spoa">Step 5: Configure Coraza-SPOA <a class="anchor" data-pagefind-ignore href="#step-5-configure-coraza-spoa" aria-label="Link to this section">#</a></h2>
<p>This file tells the agent where to listen and which rules to load.</p>
<ul>
<li><code>bind: 127.0.0.1:9000</code>: the port HAProxy connects to. Localhost only.</li>
<li><code>applications</code>: a named rule set. HAProxy picks it per request (<code>app=str(haproxy_waf)</code> in Step 9); <code>default_application</code> is used otherwise.</li>
<li><code>directives</code>: the rules, loaded in order: Coraza base settings, CRS setup, CRS plugins, then the CRS rules.</li>
<li><code>response_check: false</code>: only requests are inspected.</li>
<li><code>transaction_ttl_ms</code>: how long the agent keeps a transaction&rsquo;s state.</li>
</ul>
<p>Edit <code>/etc/coraza-spoa/config.yaml</code>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="c"># Bind address</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">bind</span><span class="p">:</span><span class="w"> </span><span class="m">127.0.0.1</span><span class="p">:</span><span class="m">9000</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">log_level</span><span class="p">:</span><span class="w"> </span><span class="l">info</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">log_file</span><span class="p">:</span><span class="w"> </span><span class="l">/var/log/coraza-spoa/server.log</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">log_format</span><span class="p">:</span><span class="w"> </span><span class="l">console</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">default_application</span><span class="p">:</span><span class="w"> </span><span class="l">haproxy_waf</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">applications</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">haproxy_waf</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">directives</span><span class="p">:</span><span class="w"> </span><span class="p">|</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd">      Include /etc/coraza-spoa/coraza.conf
</span></span></span><span class="line"><span class="cl"><span class="sd">      Include /etc/coraza-spoa/crs-setup.conf
</span></span></span><span class="line"><span class="cl"><span class="sd">      Include /etc/coraza-spoa/plugins/*-config.conf
</span></span></span><span class="line"><span class="cl"><span class="sd">      Include /etc/coraza-spoa/rules/*.conf</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">response_check</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">transaction_ttl_ms</span><span class="p">:</span><span class="w"> </span><span class="m">60000</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">log_level</span><span class="p">:</span><span class="w"> </span><span class="l">info</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">log_file</span><span class="p">:</span><span class="w"> </span><span class="l">/var/log/coraza-spoa/server.log</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">log_format</span><span class="p">:</span><span class="w"> </span><span class="l">console</span><span class="w">
</span></span></span></code></pre></div><h2 id="step-6-configure-coraza-rules">Step 6: Configure Coraza Rules <a class="anchor" data-pagefind-ignore href="#step-6-configure-coraza-rules" aria-label="Link to this section">#</a></h2>
<p>Create <code>/etc/coraza-spoa/coraza.conf</code> from the Coraza recommended configuration and add the OWASP Core Rule Set.</p>
<table>
	<thead>
			<tr>
					<th>Mode</th>
					<th>Use it for</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td><code>SecRuleEngine DetectionOnly</code></td>
					<td>A new site: log matches, block nothing, tune false positives first</td>
			</tr>
			<tr>
					<td><code>SecRuleEngine On</code></td>
					<td>Blocking mode, once the rules fit your application (the <code>sed</code> below sets this)</td>
			</tr>
	</tbody>
</table>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Coraza base configuration; switch DetectionOnly to On for blocking mode</span>
</span></span><span class="line"><span class="cl">wget -O /etc/coraza-spoa/coraza.conf <span class="se">\
</span></span></span><span class="line"><span class="cl">  https://raw.githubusercontent.com/corazawaf/coraza/v3.8.1/coraza.conf-recommended
</span></span><span class="line"><span class="cl">sed -i <span class="s1">&#39;s/^SecRuleEngine DetectionOnly/SecRuleEngine On/&#39;</span> /etc/coraza-spoa/coraza.conf
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># OWASP Core Rule Set v4 (the version bundled with current coraza-spoa)</span>
</span></span><span class="line"><span class="cl">git clone --depth <span class="m">1</span> --branch v4.25.0 https://github.com/coreruleset/coreruleset.git
</span></span><span class="line"><span class="cl">cp -p coreruleset/crs-setup.conf.example /etc/coraza-spoa/crs-setup.conf
</span></span><span class="line"><span class="cl">cp -Rp coreruleset/rules /etc/coraza-spoa/
</span></span></code></pre></div><h2 id="step-7-system-configuration">Step 7: System Configuration <a class="anchor" data-pagefind-ignore href="#step-7-system-configuration" aria-label="Link to this section">#</a></h2>
<p>The repository ships a systemd unit and a logrotate file in <code>contrib/</code>. The unit runs the agent as <code>coraza-spoa</code> and creates the log directory; logrotate keeps the logs from filling the disk.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Copy log rotation configuration and systemd unit files</span>
</span></span><span class="line"><span class="cl">cp -Rp contrib/coraza-spoa.logrotate /etc/logrotate.d/coraza-spoa
</span></span><span class="line"><span class="cl">cp -Rp contrib/coraza-spoa.service /lib/systemd/system/
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Reload systemd and enable the Coraza-SPOA agent</span>
</span></span><span class="line"><span class="cl">systemctl daemon-reload
</span></span><span class="line"><span class="cl">systemctl <span class="nb">enable</span> coraza-spoa.service
</span></span><span class="line"><span class="cl">systemctl start coraza-spoa.service
</span></span></code></pre></div><h2 id="step-8-configure-haproxy">Step 8: Configure HAProxy <a class="anchor" data-pagefind-ignore href="#step-8-configure-haproxy" aria-label="Link to this section">#</a></h2>
<p>If HAProxy is not installed yet, install it from the official HAProxy packages rather than the distribution&rsquo;s older <code>haproxy</code> package:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="c1"># Official HAProxy packages for Ubuntu 24.04: one PPA per branch</span>
</span></span><span class="line"><span class="cl">sudo add-apt-repository -y ppa:vbernat/haproxy-3.3
</span></span><span class="line"><span class="cl">sudo apt update
</span></span><span class="line"><span class="cl">sudo apt install -y <span class="nv">haproxy</span><span class="o">=</span>3.3.<span class="se">\*</span>
</span></span><span class="line"><span class="cl">haproxy -v
</span></span></code></pre></div><p>3.3 is the newest branch the PPA builds for Ubuntu 24.04, but it is a short-lived stable branch, maintained until about Q1 2027. The newest LTS branch, 3.4, is built for Ubuntu 26.04 (<code>ppa:vbernat/haproxy-3.4</code>) and for Debian 13 on <a href="https://haproxy.debian.net/" rel="noopener">haproxy.debian.net</a>, which lists the repository lines per release and branch. For a long-lived Ubuntu 24.04 install, use the 3.2 LTS branch instead (<code>ppa:vbernat/haproxy-3.2</code>, maintained until 2030).</p>
<p>HAProxy configuration consists of three main steps:</p>
<ol>
<li>Create the frontend.</li>
<li>Create backends for Coraza-SPOA and static content.</li>
<li>Configure the SPOE engine.</li>
</ol>
<p>What the frontend does:</p>
<ul>
<li><code>filter spoe engine coraza</code>: sends every request to the agent, using the SPOE file from Step 9.</li>
<li>First <code>deny</code>: Coraza&rsquo;s verdict is <code>deny</code> → 403.</li>
<li>Second <code>deny</code>: the agent could not be reached or timed out → 500. The WAF fails closed: no verdict, no access.</li>
<li><code>backend coraza-spoa</code>: the agent itself, in <code>mode tcp</code> because SPOP is not HTTP.</li>
</ul>
<p>Add the following frontend and backend configurations in <code>/etc/haproxy/haproxy.cfg</code>:</p>
<pre tabindex="0"><code class="language-haproxy" data-lang="haproxy">frontend static_test
    mode http
    bind *:80
    filter spoe engine coraza config /etc/haproxy/coraza.cfg
    # Act on the verdict Coraza returns in txn.coraza.action
    http-request deny deny_status 403 if { var(txn.coraza.action) -m str deny }
    http-request deny deny_status 500 if { var(txn.coraza.error) -m int gt 0 }
    use_backend bsdserver_static

backend bsdserver_static
    mode http
    http-request return status 200 content-type &#34;text/plain&#34; string &#34;Welcome!\n&#34;

backend coraza-spoa
    mode tcp
    balance roundrobin
    server s1 127.0.0.1:9000
</code></pre><h2 id="step-9-spoe-configuration-for-haproxy">Step 9: SPOE Configuration for HAProxy <a class="anchor" data-pagefind-ignore href="#step-9-spoe-configuration-for-haproxy" aria-label="Link to this section">#</a></h2>
<p>SPOE (Stream Processing Offload Engine) is how HAProxy hands request data to an external agent. This file says what to send and where the answer goes.</p>
<ul>
<li><code>option var-prefix coraza</code>: the agent&rsquo;s answers become <code>txn.coraza.*</code> variables, such as <code>txn.coraza.action</code>.</li>
<li><code>option set-on-error error</code>: sets <code>txn.coraza.error</code> when the agent fails, which the frontend turns into a 500.</li>
<li><code>timeout processing 500ms</code>: how long HAProxy waits for a verdict.</li>
<li><code>args</code>: the request parts Coraza inspects, including headers and body.</li>
<li><code>event on-frontend-http-request</code>: send the message for every request in the frontend.</li>
</ul>
<p>Edit <code>/etc/haproxy/coraza.cfg</code>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-cfg" data-lang="cfg"><span class="line"><span class="cl"><span class="k">[coraza]</span>
</span></span><span class="line"><span class="cl"><span class="na">spoe-agent coraza-agent</span>
</span></span><span class="line"><span class="cl">    <span class="na">messages coraza-req</span>
</span></span><span class="line"><span class="cl">    <span class="na">option var-prefix coraza</span>
</span></span><span class="line"><span class="cl">    <span class="na">option set-on-error error</span>
</span></span><span class="line"><span class="cl">    <span class="na">timeout processing 500ms</span>
</span></span><span class="line"><span class="cl">    <span class="na">use-backend coraza-spoa</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="na">spoe-message coraza-req</span>
</span></span><span class="line"><span class="cl">    <span class="c1"># Arguments are required to be in this order</span>
</span></span><span class="line"><span class="cl">    <span class="na">args app</span><span class="o">=</span><span class="s">str(haproxy_waf) 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
</span></span></span><span class="line"><span class="cl"><span class="s">    event on-frontend-http-request</span>
</span></span></code></pre></div><h2 id="step-10-validate-and-start-haproxy">Step 10: Validate and Start HAProxy <a class="anchor" data-pagefind-ignore href="#step-10-validate-and-start-haproxy" aria-label="Link to this section">#</a></h2>
<p>Check the configuration before you restart HAProxy.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl">haproxy -c -V -f /etc/haproxy/haproxy.cfg
</span></span></code></pre></div><p>If there are no errors, enable and restart HAProxy:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sh" data-lang="sh"><span class="line"><span class="cl"><span class="c1"># Enable HAProxy</span>
</span></span><span class="line"><span class="cl">systemctl <span class="nb">enable</span> haproxy.service
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Restart HAProxy (the Ubuntu/Debian package already started it with the</span>
</span></span><span class="line"><span class="cl"><span class="c1"># default configuration, so &#34;start&#34; would not load the new one)</span>
</span></span><span class="line"><span class="cl">systemctl restart haproxy.service
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="c1"># Verify status</span>
</span></span><span class="line"><span class="cl">systemctl status haproxy.service
</span></span></code></pre></div><h2 id="troubleshooting">Troubleshooting <a class="anchor" data-pagefind-ignore href="#troubleshooting" aria-label="Link to this section">#</a></h2>
<table>
	<thead>
			<tr>
					<th>Symptom</th>
					<th>Cause / fix</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Every request gets a 500</td>
					<td>HAProxy cannot reach the agent: check <code>systemctl status coraza-spoa</code> and that it listens on <code>127.0.0.1:9000</code></td>
			</tr>
			<tr>
					<td>Legitimate requests get a 403</td>
					<td>A CRS false positive: check the Coraza logs for the rule ID; run in <code>DetectionOnly</code> while tuning</td>
			</tr>
			<tr>
					<td>Agent does not start</td>
					<td>A rule file fails to load: check the agent&rsquo;s log in <code>/var/log/coraza-spoa/</code></td>
			</tr>
	</tbody>
</table>
<h2 id="security-considerations">Security Considerations <a class="anchor" data-pagefind-ignore href="#security-considerations" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Fail closed.</strong> The <code>txn.coraza.error</code> rule blocks requests when the WAF is down. Remove it only if availability matters more than protection.</li>
<li><strong>Agent on localhost.</strong> Keep <code>bind: 127.0.0.1:9000</code>; anyone who can talk to the agent can see request data.</li>
<li><strong>Keep the CRS current.</strong> Update the rules with new CRS releases.</li>
<li><strong>A WAF is an extra layer.</strong> It does not replace patching and input validation in the application.</li>
</ul>
<h2 id="automate-it">Automate it <a class="anchor" data-pagefind-ignore href="#automate-it" aria-label="Link to this section">#</a></h2>
<p>The Ansible roles and Terraform code that build this setup are on GitHub:
<a href="https://github.com/pderuiter/blog-haproxy-coraza" rel="noopener">pderuiter/blog-haproxy-coraza</a>. It creates an Ubuntu 24.04 VM, installs HAProxy from the official packages, builds Coraza-SPOA with the Core Rule Set and wires it into HAProxy; <code>terraform apply</code> followed by <code>ansible-playbook site.yml</code> gives you the blocking WAF from this guide.</p>
<h2 id="conclusion">Conclusion <a class="anchor" data-pagefind-ignore href="#conclusion" aria-label="Link to this section">#</a></h2>
<p>You&rsquo;ve now set up Coraza-SPOA integrated with HAProxy: a WAF that checks every request against the Core Rule Set before it reaches your application. Coraza can inspect both incoming and outgoing traffic; this setup checks requests (response inspection needs <code>response_check: true</code> and a <code>coraza-res</code> SPOE message).</p>
<p>For more information and additional configurations, visit:</p>
<ul>
<li><a href="https://github.com/corazawaf/coraza-spoa" rel="noopener">Coraza-SPOA GitHub</a></li>
<li><a href="https://github.com/haproxy/haproxy/blob/master/doc/SPOE.txt" rel="noopener">HAProxy Documentation for SPOE</a></li>
</ul>
<p>Start in detection mode on a real site, tune the false positives, then switch to blocking.</p>
]]></content:encoded></item></channel></rss>