Logo Codebaker
IT

BunkerWeb at Codebaker: the open-source WAF that plays nice with Kubernetes

by Codebaker ·

BunkerWeb at Codebaker: the open-source WAF that plays nice with Kubernetes

Web application security should not be an exercise reserved for network experts with ten years of experience. And yet, configuring a Web Application Firewall (WAF) correctly and keeping it maintained over time is often a task that intimidates even the most experienced teams.

BunkerWeb was born to change this dynamic. In this article we explain what it is, how it works, and above all how we integrated it into our own infrastructure, in the office and in production, with an architecture designed for high availability.

What is BunkerWeb

BunkerWeb is an open-source WAF based on Nginx and ModSecurity, developed by Bunker (now part of laudilabs). The core idea is simple: unify reverse proxy, WAF and TLS termination in a single image, reducing the configuration surface and the number of components to maintain.

In practice, BunkerWeb sits in front of your applications and:

  • Terminates TLS (managing certificates and protocols).
  • Filters traffic with ModSecurity rules (OWASP CRS and custom rules).
  • Acts as a reverse proxy towards the backends.
  • Exposes a simple, file- and variable-based configuration interface that lends itself well to declarative management.

Compared to a classic Nginx + ModSecurity setup, the advantage is that everything lives in a single Docker image: fewer components, fewer points of misalignment, an upgrade that touches a single artifact.

Why we chose it

When we needed to put a WAF in front of our services, the requirements were clear:

  • Open source, no licenses to manage.
  • Simple to configure and to update over time.
  • Compatible with Docker and Kubernetes, because our production runs on Kubernetes.
  • Ready-to-use OWASP CRS rules, with the ability to customize them.
  • A declarative configuration model that lends itself to Git versioning.

BunkerWeb satisfies all of them, and the fact that it is maintained by an active team (laudilabs) gave us further confidence.

How we integrated it at Codebaker

Now for the core of the article: we did not stop at reading the documentation, we put it into production in two different contexts.

In the office: first point of contact after the perimeter firewall

In the office, BunkerWeb is the first point of contact for all inbound traffic, right after the perimeter firewall. Every request coming from outside first passes through the firewall (which does basic network-level filtering) and then through BunkerWeb, which applies the WAF rules and terminates TLS before forwarding the request to the internal services.

This gives us defense in depth: the perimeter firewall blocks unauthorized traffic at the network level, BunkerWeb blocks application-level attacks (injection, XSS, path traversal, etc.), and the internal services are never directly exposed.

In production: Kubernetes on Scaleway

In production, BunkerWeb runs on Kubernetes, on our Scaleway cluster. Each role has its own dedicated pods:

  • The WAF pods, which serve the traffic.
  • The pod (or machine) dedicated to configuration, which manages rules, certificates and parameters.

Separating the WAF pods from the configuration node is an important architectural choice: configurations can be updated, versioned and managed independently of the traffic, without having to touch the nodes that serve the requests.

High-availability architecture

The point we cared about most was continuity: a WAF that goes down must not take the service down. For this reason we designed a high-availability (HA) architecture with three elements:

  • Two active, independent WAF nodes, in parallel.
  • A separate node (machine or pod) dedicated to configuration.
  • A load balancer in front of the two WAF nodes.

The two WAF nodes are completely independent: they share no state and do not depend on each other. If one of them goes down, the other keeps serving all the traffic without interruption.

The configuration node is separate because it has a different role: it distributes rules, certificates and parameters to the WAF nodes. If the configuration node goes down, the active WAF nodes keep running with the already-loaded configurations: you lose the ability to update the rules until the config node is back, but the service is not interrupted.

In short:

  • One WAF node goes down: the other keeps serving the traffic.
  • The configuration node goes down: the active WAF nodes keep running with the already-loaded rules.
  • One WAF node and the configuration node go down: the service keeps running with the single active WAF node.

This is the property we were looking for: no single point of failure that can take the service down.

Configuration and long-term management

BunkerWeb's configuration is declarative and file-based, which makes it ideal for Git versioning. Rules, certificates and parameters live in a repository, are reviewed and applied to the nodes in a traceable way.

This fits well with our GitOps approach: every configuration change goes through a pull request, is reviewed and applied automatically to the nodes. No manual changes, no untracked state.

Conclusions

BunkerWeb gave us what we were looking for: an open-source WAF, simple to configure, Kubernetes-compatible, with a declarative model that lends itself to long-term management. The HA architecture we built around it (2 active, independent WAF nodes plus a separate config node) guarantees the operational continuity that such a critical component requires.

If you are evaluating a WAF for your infrastructure, BunkerWeb deserves a spot at the top of the list, especially if you already work with Docker and Kubernetes.

Sources