When Wazuh load balancing with NGINX fits your cluster
NGINX fits when agents currently point at one Wazuh server address and you need that traffic spread across several worker nodes, and when your team can own a Layer 4 proxy in front of the cluster. The NGINX layer is a TCP pass-through for agent traffic, not a Wazuh-aware component. It does not read agent state, decide which node an agent belongs to, or replace the cluster's own role model. Under the Wazuh components documentation, the server can run as a cluster for horizontal scaling, and the master still manages agent configuration and upgrades, so the proxy only decides where connections land.
Because NGINX works at the stream level, the decision you are really making is about enrollment and session stickiness. Enrollment traffic has to reach the master, while ongoing event traffic should reach workers, and an agent should keep returning to the same worker so its state stays consistent. Confirm in the Wazuh cluster documentation which ports and roles each node type serves, and confirm in the NGINX documentation how the stream module supports hashing on a client key and how upstream health checks behave in the version you run. Also confirm whether your NGINX build includes the stream modules you need.
Before committing, check whether HAProxy is the better fit for your team, since the sibling topic on HAProxy covers registration and reporting frontends, leastconn balancing and a helper that rebalances agents as workers change. NGINX without an equivalent helper means you must plan manually how agents move when a worker is added or lost. Ask your Wazuh partner or internal team to write down the expected agent distribution, the failure behavior for each node, and who will test both before production traffic is switched.
How enrollment and event traffic reach the master and workers
Agents start at the NGINX stream tier, which sits behind a trust boundary on the agent side. Enrollment traffic on the registration port goes to the Wazuh master, while agent event traffic on the reporting port goes through a hashed upstream to the workers. The Wazuh indexer and dashboard sit behind the server layer, so the proxy never reaches them directly. Check that both proxy listeners map to the right node groups and that the hash key keeps each agent on one worker.
Enrollment goes to the master and events go to hashed workers, behind two trust boundaries.
Why enrollment goes to the master and events go to workers
Agent enrollment and ongoing event reporting are two different kinds of traffic, and the NGINX design only works if each one lands on the node that owns it. Enrollment is the one-time exchange where an agent registers with the Wazuh server and receives its key, and it is handled by the master. Event reporting is the continuous stream of agent data that the workers analyze. Before you write any stream block, confirm with the Wazuh components documentation and the cluster documentation which services run on the master and which run on workers in your Wazuh release line, because the split must follow that map rather than an assumption about it.
If both traffic types go to the same pool, several things can go wrong. An agent may be sent to a node that does not hold the registration state it needs, so enrollment fails or produces a key the rest of the cluster does not recognize. A worker that accepts a registration it should not handle can also create duplicate or conflicting agent records. Health checks can mask the problem, since a worker that answers on the listening port may still be unfit for registration. Changes to the pool, such as adding a worker, can then reshuffle enrollment traffic in ways that are hard to trace back to the cause.
In practice, plan two upstream groups in NGINX: one for enrollment that points only at the master, and one for event reporting that points at the workers with consistent hashing. Ask your Wazuh contact or review the release notes for your exact version to confirm the listening ports for each service before you fix them in configuration. Test an enrollment from a clean test agent after every change, and confirm in the manager that the agent appears once, under the expected name, with a single key.
Which NGINX stream options fit each traffic type
This table compares the stream configuration choices for Wazuh enrollment and agent reporting traffic, with the fit and trade-off of each option. Read each row as a decision: find the traffic type you are routing, then check what the option gains and what it gives up. Directive names are marked for confirmation against the NGINX documentation for your installed version.
| Decision | When it fits | What it trades away |
|---|---|---|
| Separate upstream groups for enrollment and reporting | Enrollment goes to the master and reporting goes to workers, so each group needs its own pool and port. Confirm the upstream and stream block layout for your NGINX version. | Two groups mean two sets of health checks and two places to change when a node is added or removed. |
| Single upstream group for all agent traffic | Small test clusters where one pool can serve both enrollment and reporting without tying enrollment to the master. | Enrollment can reach a worker that does not hold the registration state the team expects, so behavior is harder to predict. |
| Hash key on client address | Agents sit on stable addresses and you want the same agent to reach the same worker across connections. Confirm the hash directive and the $remote_addr variable in the stream module reference. | Agents behind shared NAT or a shared egress address can concentrate on one worker. Agents that change address are rebalanced without warning. |
| Hash key on agent identity | You want affinity tied to the agent rather than its network path, which suits agents that move between networks. Confirm which variables are available at the stream layer for your version before relying on one. | Agent identity is not always visible to NGINX at the stream layer, so the key may need a workaround. Test it against real agent reconnects first. |
| Consistent hashing | Adding or removing a worker moves only part of the agents, which limits reconnect storms. Confirm the consistent parameter of hash in your NGINX build. | Distribution can be less even across a small number of workers, so check load per worker after changes. |
| Plain hashing | Fixed-size clusters that rarely change, where simple and predictable mapping is enough. | Adding or removing a worker remaps most agents at once, which can flood the cluster with reconnects. |
| Health checks and timeouts for long-lived connections | Agent sessions stay open for long periods, so timeouts must exceed normal keepalive intervals. Confirm proxy_timeout, proxy_connect_timeout and any passive or active health check options in your version, since active checks may require NGINX Plus. | Long timeouts keep dead connections open longer. Short timeouts cause agents to drop and reconnect during quiet periods. |
| Terminate TLS at NGINX | You need NGINX to inspect or manage TLS, and you accept that agents will not authenticate the Wazuh server directly. Confirm ssl_preread and proxy_ssl behavior before choosing. | NGINX holds decrypted traffic and becomes a sensitive point, and certificate trust between agents and the server changes. |
| Pass through TLS (stream proxy without termination) | Agents keep their mutual trust with the Wazuh server, and NGINX only forwards bytes. This is the usual choice for agent traffic. | NGINX cannot inspect or route on message content, so routing decisions rely only on connection-level data such as addresses and ports. |
Decisions to settle before writing the NGINX configuration
Six decisions shape the NGINX configuration for Wazuh agents, and most of them depend on each other: the size of the worker pool, the hashing key, and how changes move through the proxy. Settle them with the Wazuh team and the network team before anyone edits a stream block, because each choice changes which agents land on which worker and who gets paged when something breaks.
Size of the worker pool
Decide how many Wazuh workers sit in the NGINX upstream pool for agent reporting traffic, and confirm the master is excluded from that pool. The count determines how many agents each worker holds and how much load a single node failure moves onto the rest. Ask the Wazuh team how many agents each worker is sized to handle in your environment, and confirm that enrollment traffic is routed to the master, not to this pool.
Wazuh componentsIdentifier used for hashing
Choose what NGINX hashes on to keep an agent on the same worker, such as the client source address or a value the agent sends. Source address hashing breaks when agents sit behind NAT or a shared egress gateway, because many agents then collapse onto one worker. Ask the network team whether agents reach the proxy directly or through translation, and test the chosen key against that real path.
Behavior when workers change
Plan what happens when a worker is added, removed or fails. With consistent hashing, most agents keep their worker, but the agents that map to the changed node still reconnect and must re-register their state. Ask the Wazuh team how agents rebalance after a change, and whether a manual rebalance step is needed before you grow or shrink the pool.
Existing HAProxy use
Find out whether the team already runs HAProxy for another path, such as the dashboard or the API. Running two proxies for the same Wazuh traffic adds a second place to troubleshoot and a second set of health checks. Ask the network team which proxy is the approved standard, and whether a stream-based NGINX tier already exists that you can extend without a new service.
Owner of the proxy configuration
Name one team that owns the NGINX configuration, its certificates and its reload process. Without a clear owner, a change made by the security team for a new agent group can break reporting for every endpoint. Agree on who approves changes, who holds the server access, and who responds when agents stop reporting through the proxy.
Testing and change control
Decide how a configuration change is validated before it reaches production, including a syntax check, a staging proxy and a test agent group. Ask the network team whether a staging environment with a few enrolled agents is available, and agree on the rollback steps and the signals that show agents are still reporting after a reload.
Configuring NGINX stream upstreams step by step
This sequence builds an NGINX stream proxy that sends agent enrollment to the Wazuh master and agent event traffic to the workers, with consistent hashing so each agent keeps returning to the same worker. Each step ends with a check that proves the proxy behaves as intended before agents depend on it.
Confirm cluster health and node roles
Before touching the proxy, the team confirms that the Wazuh cluster is healthy and that the node roles are written down. One node is the master, the others are workers, and each worker's address and the ports agents use must be known. The platform or Wazuh administrator runs the cluster status checks described in the Wazuh documentation on the master. The step is done when every expected node reports as connected and the team has a short table of node names, addresses and roles to use in the next steps.
Confirm the NGINX stream module is available
The proxy host needs an NGINX build that includes the stream module, and the configuration must be read from a stream block separate from the HTTP block. The infrastructure team checks the installed build and the include path used by the main configuration file. Confirm the exact package and module behavior against NGINX's own documentation for your distribution. The step is done when the stream module loads without errors on a test configuration and the team has confirmed which file the stream block will live in.
Define separate upstreams for enrollment and events
The team writes two upstream groups in the stream block. The enrollment upstream points only at the master, because registration must reach the node that manages agent keys. The event upstream lists the workers, where agents send ongoing reports. Each listen block then forwards to the matching upstream. Keeping these apart prevents enrollment traffic from landing on a worker that cannot complete it. The step is done when the configuration validates and the two upstream names are visibly distinct in the file.
Apply consistent hashing to the event upstream
On the event upstream, the team adds a hash directive keyed on the client address so that a given agent is mapped to the same worker on each connection attempt. The hash method and key should be chosen with the Wazuh and NGINX documentation in view, and the team should confirm how the chosen key behaves when agents sit behind NAT. The step is done when the configuration reloads cleanly and the hash directive appears only on the event upstream, not the enrollment upstream.
Set timeouts for persistent agent connections
Agents keep long-lived connections open to report events, so default idle timeouts can close them between messages. The team sets proxy timeout values on both listen blocks that are longer than the agent's normal quiet period, and confirms the values against the agent's keepalive behavior in the Wazuh documentation. Timeouts that are too short cause repeated reconnects, and timeouts that are too long hold dead connections open. The step is done when the timeout settings are documented in the change record with the reason for each value.
Validate and reload the proxy
The administrator runs NGINX's configuration test and reads any warnings before reloading the service, so that a syntax error does not interrupt agents already connected. After the test passes, the service is reloaded rather than restarted. The team checks the error log for upstream connection failures. The step is done when the configuration test passes with no errors, the reload completes, and the proxy is listening on the expected ports.
Enroll a test agent through the proxy
A non-production test agent is pointed at the proxy address rather than at the master or a worker directly. The agent enrolls, and the team confirms on the master that the enrollment completed and that the agent appears in the agent list. This check shows that the enrollment upstream is working. The step is done when the agent is registered on the master and the proxy log shows the enrollment connection forwarded to the master address.
Confirm stable worker assignment across reconnects
The team restarts the test agent or forces a reconnect, then checks which worker received its events both times. The test is repeated several times, and the same worker should appear each time while all workers stay in service. The team also records the result for each worker so that any unexpected movement is traced to a configuration or node health change. The step is done when the test agent consistently lands on the same worker across reconnects, and the result is saved with the configuration version.
How to validate the configuration before go-live
Validate the NGINX stream configuration in stages before any production agent points at it. Start with a syntax check of the full configuration, then confirm that the enrollment path and the event path behave as separate routes. Test enrollment first with a small set of lab agents pointed at the proxy's enrollment port, and confirm the agent registers with the master even while the event upstream is stopped or unreachable. If enrollment fails when the worker group is down, the routing split is wrong and go-live should wait.
Next, run a staged test with a small, representative set of agents on a dedicated group. Confirm that each agent keeps reporting to the same worker across reconnects, which is the point of the consistent hashing decision. Then stop one worker on purpose and observe what happens: the affected agents should reconnect to a surviving worker, and the rest should stay where they were. Record how long reconnection takes and whether any agent stays disconnected, because that timing decides the reconnect and failover settings you will need later. Use a clearly labeled illustrative table of agent-to-worker assignments before and after the test so the change is easy to review.
Review logs on both sides before sign-off. On the proxy, look for upstream connection errors and refused or reset streams. On the Wazuh nodes, check the manager logs for agent connection and authentication events. Keep dated copies of the NGINX configuration, the syntax check output, the staged test results, and the log excerpts as change evidence. The exact log file locations, the test commands and the NGINX stream directives must be confirmed against the Wazuh and NGINX versions you have installed, using the Wazuh documentation for the release you run.
Security and operational risks of the proxy tier
The NGINX tier sits between every agent and the Wazuh server cluster, so it becomes a target, a single point of failure and a source of drift if it is not managed as carefully as the nodes behind it. The cards below pair each risk with a control the team can put in place and check before go-live.
Single point of failure
One NGINX instance in front of the cluster means every agent loses its path to the server when that host fails, even though all workers are healthy. Run at least two proxy instances behind a virtual IP managed by a failover tool, or publish several proxy addresses in agent configuration. Test a planned failover in a lab and confirm agents reconnect within the timers you set. Ask your network team who owns the virtual IP and how it is monitored.
Wazuh deployment optionsTopology exposed by proxy configuration
The NGINX configuration lists every worker address and the ports used for enrollment and event traffic, which gives an attacker a map of the cluster if the file or the admin interface leaks. Restrict read access to the configuration file to root and the service account, keep the proxy management interface off user networks, and use a dedicated management path. Review who can edit the file through your privileged access process.
Certificates at the proxy and nodes
The proxy terminates or passes through connections that carry agent credentials and enrollment traffic, so each hop needs a defined certificate approach. Decide whether TLS is terminated at NGINX or passed through to the manager, track certificate expiry for every hop in one inventory, and confirm that the proxy trusts only the internal CA you operate. Check the expiry date of each certificate in your monitoring before go-live.
Source address logging for investigations
Behind a proxy, the cluster sees the proxy address rather than the agent address unless the source is passed along or logged at the proxy. Without that, an incident responder cannot tie an alert or a connection to a specific endpoint. Configure NGINX access logs to record the client address, send them to your central log store, and test that you can trace one agent from the proxy log to its Wazuh alert.
Change control for upstream edits
Adding or removing a worker changes the upstream block, and an unreviewed edit can route enrollment to the wrong node or drop a worker from rotation. Keep the NGINX configuration in version control, require review for upstream changes, and run the configuration test before every reload. Record which worker addresses are expected so a reviewer can compare the change with the intended cluster layout.
Proxy health monitoring
A proxy that accepts connections but forwards them to unhealthy workers can look up while agents silently stop reporting. Monitor the NGINX process, the listening ports, error log volume and upstream failures, and alert when the number of agents reporting through the proxy drops. Confirm that your monitoring checks the proxy and the workers separately so a healthy proxy does not hide a failed node.
What buyers ask about Wazuh load balancing with NGINX
What drives the effort of putting NGINX in front of a Wazuh cluster?
The main drivers are how many agents report to the cluster, how many workers sit behind the proxy, and how many agent groups and enrollment paths you must keep separate. Each additional worker adds a backend to the stream configuration and a health check to plan. The work also grows with the number of network zones, because each zone may need its own routing rule, firewall opening and test path. Ask the partner to show how the stream blocks map to your ports, nodes and agent populations before agreeing the scope.
How long does this work take in general terms?
Duration depends less on NGINX itself and more on the environment around it: existing Wazuh cluster health, change approval windows, firewall lead times and how many agent populations need validation. A proxy change on a small, well-documented cluster is a short piece of work, while a multi-site estate with several zones takes longer because each zone is tested separately. No duration is stated here because none has been researched for this topic. Ask for a timeline in the written scope that lists each milestone and the client actions it depends on.
What does the work need from our network, Wazuh and security teams?
The network team must confirm which addresses and ports the proxy can reach on each worker and the master, and must open the agent-facing listener from the agent networks. The Wazuh team must confirm the cluster is healthy, identify which node handles enrollment and provide the cluster key settings used by the nodes. The security team must review TLS handling, access to the proxy host and logging of agent connections. Agree these responsibilities in writing so that no change waits on an unnamed owner.
Can our internal team set up NGINX load balancing for Wazuh alone?
Yes, a team that already runs NGINX and understands Wazuh cluster roles can do this internally, since Wazuh is distributed under the GNU General Public License version 2 with an OpenSSL linking exception, which allows self-hosting without a license fee. The harder parts are testing enrollment and reporting paths separately, confirming that consistent hashing keeps agents on their assigned worker, and validating the configuration before each change. Teams without this experience usually benefit from a partner review of the first deployment. Confirm the skills and time available before deciding.
How does the cost of NGINX compare with running HAProxy?
NGINX and HAProxy are both open-source proxies, so software licensing is not the difference. The cost difference comes from which skills your team already has, how the configuration is maintained and how the health checks and failover behavior are tested. Choose the proxy your operations team can run and audit, then compare the effort for the same routing requirements. If you are also considering Wazuh Cloud, note that its plans are sold in Small, Medium, Large and Custom tiers with at least Standard support, which is a different cost model from self-hosting. Ask for both options in the same quote.
What should a quote for this work include?
A useful quote lists the current Wazuh version and cluster topology, the number of workers and agent populations in scope, the NGINX configuration to be delivered, and the validation steps for enrollment, reporting and failover. It should state which items are one-time (design, configuration, testing and handover) and which recur (patching, upgrades and reviews, if you retain support). It should also name the client inputs and the change windows assumed. Ask for the deliverables, acceptance criteria and retest approach in writing before work starts.
What do we need to confirm about the Wazuh release before changing the proxy?
Confirm the exact Wazuh server and agent versions in use, since the current release line is 4.14 and patch releases arrive roughly every one to two months. Check the release notes for changes that affect cluster communication, enrollment or agent connection handling before editing the proxy. Then test the change on a non-production cluster that mirrors your topology. Record the version pairs you validated so that future upgrades can be planned against them.
Limits to confirm in your environment
A custom NGINX layer in front of a Wazuh cluster depends on several things you have to confirm first, and none of them can be assumed from the design alone. The cards below cover the version, cluster layout, NGINX build, agent compatibility, network reach and support terms that decide whether this approach works in your environment.
Wazuh version in use
This page assumes the 4.14 release line. The latest patch in the release notes is 4.14.9, released on 14 October 2026, so confirm which patch your managers and agents run before you copy any configuration. Stream behavior, cluster ports and enrollment handling can change between patches, so test against the exact version you will deploy and record it in your change record.
Wazuh release notesCluster layout supports the chosen roles
Confirm that your cluster has one master and the number of workers you planned, and that the proxy rules you write map to the roles those nodes actually hold. Enrollment traffic should go to the master and event traffic to workers, so a layout with a different role split changes the upstream groups. Check the component roles in the Wazuh documentation before you assign backends.
Wazuh componentsNGINX build supports stream and hashing
The stream module and the hash directive used for consistent hashing must be available in the NGINX build you run, whether it comes from your distribution, a vendor package or a container image. Verify the module with the build output and run the configuration test on the exact binary in production. Some minimal or hardened images leave out modules, so confirm this before the design review.
Agent versions work through the proxy
Each agent version in your fleet must connect correctly through a TCP proxy to the manager ports you expose. Test a sample of every agent version and operating system you run, including older agents still in service, because enrollment and reporting behavior can differ. Record which versions pass, and plan a separate path for any that fail rather than assuming the whole fleet behaves the same.
Network policy allows proxy reach
The NGINX host must be allowed to reach the master and every worker on the cluster and agent ports, and agents must reach only the proxy address. Confirm firewall rules, security groups, routing and any inspection devices in both directions. Network teams often block the return path or a worker port after a node is added, so check these rules before cutover.
Support terms cover the proxy layer
Ask your Wazuh support provider and your internal platform owners whether a custom proxy in front of the cluster is covered by the support terms you hold. If the proxy is not covered, a problem in the path may be classified as outside vendor responsibility. Get this answer in writing and agree who owns proxy configuration, patching and troubleshooting before go-live.
How DeployOpen scopes and delivers Wazuh load balancing
DeployOpen plans NGINX stream proxying for Wazuh agent connections inside your own infrastructure, starting from your current cluster layout and agent count. We design the enrollment and event routing, build and validate the configuration in a non-production environment, and document how it behaves when a node is lost.
How we scope
- Confirm the master and worker layout, agent operating systems and network paths between agents, NGINX and each Wazuh node.
- Agree in writing which ports carry enrollment and event traffic, and which hosts run the NGINX instances.
- Define acceptance tests for sticky routing, failover and configuration validation before any build work starts.
How we build
- Write the NGINX stream configuration that sends enrollment to the master and agent events to the workers.
- Apply consistent hashing and test that a sample of agents keeps landing on the same worker across reloads.
- Run configuration syntax checks and staged agent connection tests, recording results for each change.
How we hand over
- Deliver the NGINX configuration, the test scripts and a runbook describing routing, reload and rollback steps.
- Document the agent configuration values that point to the load balancer and the checks to repeat after changes.
- Walk your operations team through failure scenarios and the evidence we captured during testing.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work begins.
- Ongoing support, upgrades and continuous testing are available as a retainer for your Wazuh environment.
- Confirm with us which Wazuh release you run before changes, since routing behavior should be re-validated after upgrades.

