When a Wazuh cluster needs HAProxy for agent load balancing
Once agents are spread across several Wazuh server nodes, they need one stable address to reach, or a way to find a working node when one fails. HAProxy is one way to front the cluster. At a high level it separates registration traffic from event reporting, balances agent connections across healthy nodes, and checks node health so that a failed worker stops receiving new connections. Teams usually reach for it when they want those controls in one dedicated, well-understood load balancer rather than in the proxy layer they already run, or when they need health-based routing with clear operational tooling.
The main alternatives are NGINX stream proxying and an agent-side list of several manager addresses. NGINX stream proxying is a sensible choice when NGINX is already the standard in your environment and your team can maintain its stream configuration, including consistent hashing so agents stay on one worker. An agent-side address list needs no extra component, but it moves failover logic onto every endpoint and makes changes to node membership harder to control. Choose HAProxy when you want a single load balancer with active health checks, and when your operations team can own its configuration, certificates and monitoring as a separate service.
Before you build anything, confirm the exact frontend, backend, health check and helper settings against the Wazuh documentation for the release you run. The current line is 4.14, and patch releases are listed in the release notes, so check the version of your server, indexer and agents, and re-verify after each upgrade. Ask whether your planned topology needs the helper that rebalances agents as workers change, and who will run it. Treat the HAProxy layer as part of the cluster's change control, because a configuration mistake can stop agents from reporting even when every Wazuh node is healthy.
How HAProxy routes enrollment and agent events to Wazuh nodes
Agents start at a single HAProxy instance, which splits traffic into two frontends: a registration frontend that sends enrollment to the master, and a reporting frontend that sends event traffic to the workers. The master and workers sit behind the balancer and feed the Wazuh indexer, which the Wazuh dashboard reads from. The health check paths decide which workers receive traffic, and the rebalancing helper acts when the worker set changes. Check that enrollment never reaches a worker and that each worker is marked down when its health check fails.
Agent traffic split between registration and reporting frontends in front of the Wazuh server layer.
HAProxy frontend and backend options and when each fits
This table compares the main HAProxy design choices for fronting a Wazuh cluster: frontend layout, balancing algorithm, proxy mode and whether rebalancing is automated. Read each row for its trade-off and the effect on agent stickiness, enrollment security and day-to-day effort, then match the option to your cluster size and change process.
| Design choice | Option | Trade-off | When it fits |
|---|---|---|---|
| Frontend layout | Single shared frontend | One listener serves enrollment and event traffic, so routing depends on a single backend pool and enrollment traffic shares its path with reporting. | Small clusters where one entry point is acceptable and enrollment can reach any node without a separate policy. |
| Frontend layout | Separate registration and reporting frontends | Enrollment goes to the master and events go to workers, so the enrollment path can be restricted and monitored on its own. | Clusters that want enrollment isolated from event ingestion, which matches the master and worker split. |
| Balancing algorithm | leastconn | New connections go to the worker with the fewest active connections, which spreads long-lived agent sessions more evenly than simple rotation. | Agents hold persistent connections, so connection count is a better load signal than request count. |
| Balancing algorithm | Round robin | Each new connection goes to the next worker in turn, which ignores how many agents a worker already holds. | Only if connection lifetimes are short and similar, which is uncommon for agent traffic. Confirm against your own connection metrics. |
| Balancing algorithm | Source hashing | The same client address maps to the same worker, which helps agents stay on one worker but can skew load when many agents share a NAT address. | Networks where agents sit behind shared egress addresses should test distribution before relying on this option. |
| Proxy mode | TCP mode | HAProxy forwards the byte stream without reading protocol content, so it stays simple and does not need to understand the agent protocol. | Agent-to-manager traffic, where the proxy only needs to choose a backend and keep the connection intact. |
| Proxy mode | HTTP-aware handling | HAProxy inspects requests, which allows header-based rules but does not fit the agent protocol and adds parsing you must maintain. | Only for API or dashboard traffic in front of the cluster, not for agent connections. |
| Helper automation | Helper runs alongside HAProxy | Backend membership updates as workers change, which lowers manual steps but adds a moving part that needs its own monitoring and access control. | Clusters that add or remove workers often and have the operational capacity to run and review the helper. |
| Helper automation | Helper driven manually | Operators edit backends and reload HAProxy by hand, which keeps change control explicit but makes rebalancing slower and more error-prone. | Stable clusters with infrequent worker changes and a formal change process for each edit. |
Setting up HAProxy in front of a Wazuh cluster
This sequence takes a Wazuh cluster from an agreed topology to a tested HAProxy front end, so agents enroll through one address, report to workers, and keep working when a node changes. Each step ends with a check you can run before moving on.
Confirm cluster topology and node roles
Start by writing down the master node, each worker node, the Wazuh indexer and dashboard addresses, and the ports each role uses. Confirm which node handles enrollment and which nodes receive agent events in the Wazuh documentation for your release, because the cluster roles and ports are release-specific. Record this as a single inventory that the network, security and platform teams all sign off on. Done means every node has one role, one address and one owner in the inventory, and you can point to the page in the Wazuh documentation that defines each role.
Plan certificates and addresses
Decide the address that agents will use for enrollment and for reporting, and whether HAProxy will present a certificate to agents or pass the TLS session through to the Wazuh nodes. Plan the certificates for every node that agents or HAProxy must trust, and confirm the cluster key and certificate settings the Wazuh documentation requires for your version. Ask the security team who issues and rotates these certificates. Done means you have a written list of hostnames, IP addresses, certificate subjects and expiry owners, and each hostname resolves from the HAProxy host and from a test agent network segment.
Define registration and reporting frontends and backends
Create two frontends in the HAProxy configuration: one for agent registration that sends traffic to the master node, and one for agent event reporting that balances across the workers. Set the reporting backend to use the leastconn algorithm, which the approach in this topic relies on, and keep the registration backend pointed only at the master. Take the exact listening ports and directive syntax from the Wazuh documentation for your release. Done means the file defines both frontends and both backends, with every server line matching an address from your inventory.
Configure health checks
Add health checks to each backend server so HAProxy removes a node from rotation when its agent port stops responding. Choose check intervals and rise and fall thresholds that your operations team can justify, and confirm with the Wazuh documentation which port and protocol the check should probe for your release. Add a backup server only if your design calls for one. Done means you can stop the service on one worker in a lab and see HAProxy mark that server as down in its statistics output.
Validate the configuration before reload
Run HAProxy's configuration check against the file before any reload, and fix every warning about undefined backends, duplicate names, or unreachable addresses. Keep the previous working configuration as a copy so you can restore it quickly. Only reload the service once the check returns cleanly on the same host that will serve production traffic. Done means the syntax check passes on the target host, the previous configuration is saved, and the reload completes without dropping the running listeners.
Install and configure the HAProxy helper
Install the HAProxy helper that the Wazuh documentation describes for rebalancing agents as workers are added or removed, and point it at the HAProxy configuration and the Wazuh API or cluster endpoints it needs. Set the service account and file permissions so the helper can read cluster state and reload HAProxy, but cannot change unrelated settings. Confirm the exact helper package name, paths and options in the documentation for your release. Done means the helper starts under its service account, logs a successful connection to the cluster, and reports the current worker list.
Test enrollment with a small agent group
Enroll a small test group of agents through the registration frontend and confirm each one appears in the Wazuh dashboard with an assigned worker. Check that the agents show as active and that alerts from each test endpoint reach the indexer. Review the HAProxy logs and statistics to confirm enrollment hit the master and event traffic hit the workers. Done means every test agent is active, its events appear in the dashboard, and the HAProxy logs match the frontend and backend you designed.
Test rebalancing and failover before widening rollout
Stop one worker in the test environment and confirm HAProxy stops sending new traffic to it, the helper moves affected agents to the remaining workers, and events keep flowing. Then bring the worker back and confirm the helper rebalances agents onto it. Record the observed behavior and any gaps against the Wazuh documentation for your release. Only expand the agent group after both tests pass and the operations team has accepted the runbook. Done means the failover and recovery tests are written up, and the agreed rollout group is approved.
How the HAProxy helper rebalances agents as workers change
The HAProxy helper exists to move agents after the worker pool changes, so the first decision is whether your team will run it or accept placement drift. When a worker is added, the balancer starts sending new connections to it, but agents already connected to existing workers usually stay where they are until they reconnect for another reason. When a worker is removed or fails, the balancer stops routing to it once its health check fails, and the agents that were connected to it must reconnect elsewhere through their configured manager addresses. Confirm in the Wazuh documentation for your release how the helper detects these changes and whether it signals agents to move, because the exact mechanism is the part you need to verify before you depend on it.
Without rebalancing, uneven distribution can persist for a long time. A new worker may sit mostly idle while older workers keep the agents they received at connection time, and a worker that returns after a failure may start with few agents. The leastconn algorithm improves how new connections are spread by sending them to the server with the fewest active connections, but it does not move connections that are already open. The balancer can therefore report every worker as healthy while load stays concentrated on a few nodes, especially in fleets where agents rarely restart. After each change, compare agent counts and event volume per worker, and treat a persistent skew as a fault to investigate.
The helper is expected to close that gap by reassigning agents so the workers carry a more even share, which the balancer does not do on its own. Its scope should be written into your change plan: which events trigger a run, how many agents move at once, whether moves happen in a maintenance window, and what happens to agents whose reconnection fails. Because the behavior depends on the release, the helper's configuration and how your agents reconnect, test it in a staging cluster first. Add a worker, remove one and stop one under load, then record agent counts, disconnect time and any events that are lost or delayed. Rely on the helper in production only after those results match what the documentation describes.
Balancing algorithms and what they mean for agent placement
Leastconn sends each new connection to the worker with the fewest active connections at that moment. Wazuh agents hold long-lived sessions, so the connection count tracks how many agents each worker serves, which makes it a reasonable proxy for load when agents send similar volumes of data.
- Placement follows live counts: A worker that restarted or rejoined the cluster has few connections, so it attracts new agents until the counts level out.
- Existing sessions stay put: Leastconn only decides where new connections land. Agents already attached to a busy worker remain there until they reconnect, so an imbalance can persist for a long time.
- Reconnect spread after loss: When a node drops, its agents reconnect and leastconn steers them toward the survivors with the lowest counts, which usually levels the cluster quickly.
- Blind to traffic volume: Two agents count the same even if one sends far more events. Track event rate per worker alongside connection counts.
Before committing, record per-worker connection counts over several days and time how long the spread takes to return to even after you stop one worker in a test environment.
Source-based hashing takes the client's source address, computes a hash, and maps the result to one worker. While the server list is unchanged, an agent that reconnects from the same address returns to the same worker, which keeps its traffic and local state on one node.
- Stable placement: Agents keep landing on the same worker, which makes it easier to know where an agent's recent history lives during troubleshooting.
- Shared addresses skew the spread: Many agents behind one gateway or proxy share a source address and concentrate on one worker. Ask the network team how endpoints reach the cluster before choosing this method.
- Simple hashing remaps widely: With a plain modulo-style hash, changing the number of workers reassigns most agents, not only those from the lost node. Setting
hash-type consistentin HAProxy limits remapping to the lost node's share. - Uneven reconnect spread: Agents from a failed node move to whichever survivor their hash selects, so redistribution depends on address ranges and can be lopsided.
Test with agents from a single subnet and from a shared-address segment, then count how many agents change worker after you add or remove a node.
Round robin hands each new connection to the next worker in the list, regardless of how many connections or events that worker already carries. It is the simplest method to configure and explain, and it serves as a useful baseline when agents and their traffic are fairly uniform.
- Even counts, uneven load: Each worker receives the same number of new connections, but long-lived sessions can accumulate unevenly if agent activity varies.
- Predictable order: Operators can predict where the next agent lands, which helps during tests and change windows.
- Reconnect spread after loss: Reconnecting agents are dealt out in turn across the survivors, so counts even out quickly, but a worker that is already heavily loaded still receives its share.
- No protection from slow workers: A worker under heavy indexing or a slow disk keeps receiving new agents, so degradation is not avoided.
Use round robin as the control in your test, and compare per-worker event rates and connection counts against leastconn before you choose.
Security risks of a load balancer in front of Wazuh agent traffic
A load balancer in front of Wazuh agents sits on the enrollment and reporting path, so it inherits the trust placed in the manager. The cards below name the controls that keep that position safe and who should own each one, from network teams to the Wazuh administrators.
Balancer as single point of exposure
The HAProxy host accepts connections from every endpoint and forwards them to the cluster, so a compromise there reaches all agent traffic. Keep the host minimal, patch it on a fixed schedule, and limit administrative access to a named group. The network team should own the host, and the security team should review its exposure in a quarterly check of listening ports and open management paths.
Wazuh deployment optionsTLS termination or pass-through
Decide whether HAProxy terminates TLS or passes encrypted agent sessions through to the Wazuh server. Pass-through keeps the agent-to-manager channel intact end to end, while termination exposes plaintext inside the balancer and requires a separate hop to the cluster. Record where each certificate and private key lives, who can read them, and who renews them. The Wazuh administrators should own the agent-side trust chain.
Restricting registration frontend access
The registration frontend handles agent enrollment, so it should accept connections only from the address ranges where endpoints are expected to enroll. Write source-address allow lists in the frontend or in the network firewall in front of it, and deny everything else by default. The network team should own these rules, and the change should be tested by enrolling one agent from an allowed network and one from a denied network.
Balancer log retention and access
HAProxy logs show which source addresses connected, when, and to which backend, which is useful evidence during an investigation. Send these logs to the same central log platform used for Wazuh events, set a retention period that matches your policy, and restrict who can read them. Confirm with your log platform owner how long logs are kept before you write the period into the runbook.
Health check endpoint information leaks
Health checks are often exposed on an HTTP or stats page that reveals backend names, server states, and version details. Bind any stats or health endpoint to a management address, require authentication, and avoid returning more than a simple status. The security team should test the endpoint from an untrusted network to confirm it reveals nothing about the cluster layout.
Change control on HAProxy configuration
Backend lists, allow lists, and certificate paths all live in one configuration file, so an unreviewed edit can open enrollment to the internet or send agents to the wrong node. Store the file in version control, require a second reviewer for each change, and validate it before reload. The platform team should own the process, and the Wazuh administrators should approve any change to backend addresses.
Limits to confirm by environment before you rely on HAProxy
In a data center you control, HAProxy usually sits on a host or pair of hosts you manage directly, so the questions are about versions, network paths and the helper's behavior on your hardware. Confirm the HAProxy version your Wazuh release line supports, and confirm that the agent-facing ports you expose match the ports your cluster listens on. Treat the helper as a component you must test, not one you can assume works under load.
- Supported HAProxy version: Check the Wazuh documentation for the HAProxy version tested with your Wazuh release, and record it in your change ticket.
- Cluster key handling: Confirm how the cluster key is set on each node and how it is distributed, so workers accept connections the balancer forwards.
- Helper behavior under load: Run the rebalancing helper against a lab cluster with a realistic agent count and observe how long agents take to move and whether any drop.
- Health check semantics: Verify which ports HAProxy probes, how often, and what happens when a worker is slow but still listening.
- Firewall and routing: Confirm that traffic from agents reaches the balancer without NAT rules that change source addresses your workers rely on.
Before you rely on this design, reproduce a worker failure in your own lab and confirm that agents reconnect and stay balanced.
When a cloud load balancer sits in front of HAProxy, two balancing layers interact, and that interaction is where most surprises appear. The cloud service may terminate or pass through TCP, impose idle timeouts, or change source addresses before traffic reaches HAProxy. Confirm each of these with the provider's documentation and with your own tests, because the Wazuh documentation does not settle them for your provider.
- Idle timeouts: Confirm the idle timeout on the cloud load balancer and on HAProxy, and check that long-lived agent connections are not cut at the shorter limit.
- Source address preservation: Confirm whether the workers see the agent's real address or the balancer's address, since per-agent handling depends on it.
- Health check path: Confirm whether the cloud health check and HAProxy health checks probe the same ports, and whether double checks add load to workers.
- Protocol mode: Confirm that the cloud listener passes TCP through unchanged and does not inspect or rewrite the stream.
- Autoscaling of HAProxy: If the balancer runs on autoscaling instances, confirm how the configuration and the helper's state survive instance replacement.
Confirm all of these with a test cluster in the same cloud account and region before production enrollment.
On a network without internet access, the difference is delivery rather than design. Packages, the HAProxy build you install, and any vulnerability data must reach the network by an approved route. The Wazuh offline installation guide covers systems without internet connectivity, and vulnerability detection can use an offline vulnerability repository in place of the Wazuh Cyber Threat Intelligence platform. Confirm both paths against the current documentation for your release line.
- Package delivery: Confirm which HAProxy package, version and dependencies you must mirror into the enclave, and how updates will arrive later.
- Offline installation steps: Follow the Wazuh offline installation guide for the server and agent components, and confirm any balancer-specific steps it lists for your release.
- Helper dependencies: Confirm that the HAProxy helper and any scripts or runtimes it needs can be installed without online package managers.
- Certificate and key material: Confirm how certificates and the cluster key are generated and moved inside the enclave, since the usual download steps may not be available.
- Vulnerability data currency: If you use an offline repository, confirm how often it is refreshed and who approves each import.
Test the full install, including a worker replacement, using only the offline media you will carry into the enclave.
HAProxy, the helper and Wazuh components each move on their own release schedule, and a change to one can affect the others. Wazuh's 4.14 line received patch releases on 17 March, 23 April, 1 July, 29 July, 23 September and 14 October 2026, so confirm the balancer configuration against the exact patch you deploy, not only the minor line. Plan upgrades so that balancer changes and Wazuh changes are tested together.
- Patch-level compatibility: Check the release notes for the patch you deploy and confirm the balancer setup remains valid.
- Helper version pinning: Pin the helper version you tested and confirm how it behaves against the Wazuh version in each cluster node.
- Rollback path: Confirm that you can restore the previous HAProxy configuration and helper state within your change window.
- Staged rollout: Confirm whether you can move a subset of agents to a new balancer configuration before switching all of them.
- Support boundaries: Ask whether the vendor or your partner covers HAProxy itself, the helper, or only the Wazuh side.
Record each tested combination of versions in your runbook so the next upgrade starts from evidence.
Once the balancer is running, the question becomes whether you can show that it works and keep it working. Auditors, security reviewers and your own operations team will ask for evidence of health checks, failover events and the balance of agents across workers. Confirm what the helper logs, what HAProxy exposes for monitoring, and how long you keep those records.
- Balance evidence: Confirm how you will report the number of agents per worker over time and where that data is stored.
- Failover records: Confirm which events are logged when a worker is removed, and whether the timestamps are precise enough for an incident review.
- Monitoring integration: Confirm which HAProxy statistics you can scrape and whether they reach your existing monitoring stack.
- Retention: Confirm how long balancer and helper logs are kept and whether they fall under your data retention policy.
- Access control: Confirm who can change the balancer configuration and whether those changes are recorded.
Run a tabletop exercise that removes a worker and asks the team to produce this evidence from the logs alone.
What does a HAProxy-fronted Wazuh cluster cost and require?
What drives the effort of designing and building a HAProxy layer in front of a Wazuh cluster?
The effort is driven mostly by how many agents report in, how many Wazuh server nodes sit behind the balancer, and how many network paths and certificates must be aligned. Each frontend (registration and reporting), each backend pool, the health checks and the certificate chain are separate pieces of work. Environments with several operating system groups, segmented networks or existing firewall change processes add review time. Ask the vendor or partner to list each frontend, backend, health check and certificate they expect to touch, because that list is the best predictor of the design effort.
Can a small in-house team build and run this without outside help?
Yes, if the team already runs Linux, HAProxy and the Wazuh cluster and has someone who can read the Wazuh cluster documentation closely. The skills gap is usually not HAProxy syntax but the interaction between enrollment, agent reporting, the cluster key and the helper that rebalances agents. A small team should check whether it has the time to test failover, handle an unplanned node loss and keep the configuration in sync with Wazuh upgrades. An outside partner is most useful for the design review, the first test cycle and a written runbook, after which the team can operate the setup itself.
How long does a build and test cycle take, and what changes it?
The duration depends on environment size, the number of change windows available, and how much testing the change control process requires. Teams with a staging copy of the cluster can test configuration changes in parallel with production planning, while teams without one must schedule tests in maintenance windows. Certificate issuance, firewall requests and approvals often take longer than the HAProxy work itself. Ask for a written schedule with named dependencies, and confirm which environment will be used for failover tests before agreeing on a timeline.
What must our team provide before the work starts?
The team must provide access to the network segments and hosts where HAProxy and the Wazuh nodes run, a certificate authority or approved certificate process, an inventory of agents with their operating systems and groups, and named contacts who can approve changes. It also needs agreed maintenance windows for config reloads and failover tests. Without a current agent inventory, the rebalancing and health check design cannot be validated against real traffic. Confirm the list of required access and approvals in the written scope so that delays do not appear later as scope changes.
What recurs after go-live, and who maintains it?
After go-live, recurring work includes configuration changes when agent groups, node addresses or certificates change, Wazuh upgrades that may alter cluster behavior, and maintenance of the HAProxy helper as worker nodes are added or removed. Health check thresholds and log review also need periodic attention. These costs are ongoing rather than one-time, so the buyer should decide whether the internal team, a retainer or a mixed model will own them. Ask who approves each change and how long a rollback takes in each case.
What should we ask for in a written quote for this work?
A useful quote states the scope as a list of frontends, backends, nodes, agent groups and environments covered, plus the deliverables such as configuration files, a runbook, test results and a handover session. It should separate one-time design and build work from any recurring support or upgrade retainer, and name what is excluded, such as Wazuh cluster sizing, certificate authority setup or changes to the network firewall. Ask how failover testing is performed, which environments are used, who approves changes, and what happens if the scope changes during the build. DeployOpen agrees scope, deliverables and timelines in writing before work starts, and the quote follows from that scope.
Which parts of the Wazuh side should we confirm before asking for a quote?
Confirm the Wazuh release line you run, because the cluster behavior and the agent configuration options you depend on are tied to the version. Check the Wazuh release notes for the patch level you plan to target, and confirm with your own environment whether the cluster key and node certificates are already in place. Also confirm whether agents connect to the cluster through addresses that will change, and whether your team has a tested rollback path. These answers let the quote reflect your actual starting point rather than an assumed one.
How DeployOpen scopes and delivers Wazuh load balancing work
DeployOpen approaches HAProxy in front of a Wazuh cluster as a scoped infrastructure change, not a configuration snippet. We agree the frontends, backend pools, health checks and agent rebalancing behavior in writing, build them in your environment, and document how the setup runs after handover.
How we scope
- Inventory your current Wazuh server nodes, agent counts, network paths and any existing load balancer before design starts.
- Agree in writing which registration and reporting frontends, backend pools and health check rules the HAProxy setup will include.
- Confirm the Wazuh version line, the cluster key handling and the helper rebalancing approach with your team before build work begins.
How we build
- Deploy HAProxy in your infrastructure with leastconn balancing and health checks configured against the agreed Wazuh node ports.
- Test the configuration in a staging environment with sample agents, including a worker removal and a worker addition, before production change.
- Validate agent registration and event reporting through the load balancer and record the results against the written acceptance criteria.
How we hand over
- Deliver the HAProxy configuration, the helper setup, and a runbook covering change steps, rollback and verification commands.
- Walk your platform and security engineers through the failure scenarios tested, so they can reproduce and interpret them.
- Document which settings must be changed by hand on each Wazuh node, so future cluster changes do not silently break routing.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, scoped to your Wazuh and HAProxy versions.
- Retesting after Wazuh patch releases or cluster changes can be included in a retainer or quoted as a separate fixed-scope task.
- Ask any quote to state what is one-time work, what recurs, and which Wazuh or HAProxy upgrades are covered.

