Load balancer setup for X-Road: when a cluster needs one in front
A member running several X-Road Security Servers needs one address that consumers and providers can reach, so that traffic is spread across the nodes and a failed node stops receiving connections. An external load balancer provides that single entry point. It sits in front of the cluster, accepts connections on the ports the Security Server uses for message exchange and OCSP, and forwards each connection to a healthy node. The cluster itself, with one primary and several secondaries that share identical keys and certificates and a replicated serverconf database, is covered on the sibling page on clustering Security Servers. This page covers only the balancer in front of it.
The balancer works at the TCP level and passes TLS through without terminating it. X-Road messages are mutually authenticated between Security Servers using the member's certificates, so the TLS session must end on the Security Server itself, not on the balancer. A layer 7 proxy that decrypts traffic would break that trust model and would need its own certificates, which the design does not provide for. In practice, the balancer forwards the TCP stream on port 5500 for message exchange and on port 5577 for OCSP, and the decision to use a TCP listener rather than an HTTP listener is the first design choice to record. Confirm with your security architect how the balancer's logs will show client addresses, because a TCP proxy does not add HTTP headers.
Teams usually need an external balancer when several Security Servers must present one address to the rest of the ecosystem, when they want health-based removal of failed nodes without changing registrations, or when they run the cluster on infrastructure where DNS failover is too slow or too coarse. A member that only needs redundancy can sometimes use X-Road's built-in redundancy instead, so the choice between the two designs comes first. Before you select haproxy, nginx or AWS Network Load Balancer, confirm the balancer's TCP passthrough behavior, idle timeout settings and health check options against the product documentation for your version, and test a failover on a non-production cluster before go-live.
How client traffic reaches Security Server nodes through the load balancer
Consumer and provider systems in external networks send message exchange traffic to the load balancer on TCP 5500 and OCSP requests on TCP 5577. The load balancer passes these connections through without terminating TLS and distributes them across the primary and secondary Security Servers. Administrators and internal information systems reach each node directly on TCP 4000 and on 8080 or 8443, outside the external path. Check that the balancer does not terminate TLS, and that the internal admin and information system networks stay separate from the external listener.
External traffic flows through the balancer to cluster nodes, while admin access stays internal.
Choosing HAProxy, NGINX or AWS NLB for a Security Server cluster
This table compares HAProxy, NGINX and AWS Network Load Balancer on TCP passthrough, health checks, hosting location and ongoing ownership for a Security Server cluster. Use it to narrow the options, then confirm each candidate against the Security Server ports documented for external networks before you commit.
| Factor | HAProxy | NGINX | AWS Network Load Balancer |
|---|---|---|---|
| TCP passthrough with TLS left intact | Works in TCP mode, so the Security Server terminates TLS itself | Works through the stream module for TCP, so TLS is not decrypted | Works at Layer 4, so TLS is passed through to the nodes |
| Health check depth | TCP and HTTP checks configurable per backend, with tunable intervals and thresholds | Passive and active health checks depend on the build and modules, so confirm the features in your version | TCP, HTTP and HTTPS target health checks configured on the target group |
| Ports to balance | Each external port your design needs, such as 5500 and 5577, must be defined explicitly | Each external port must be declared in a stream block, confirm the ports against your design | One listener and target group per port, such as 5500 and 5577 |
| Where it runs | Your own virtual machines, containers or bare metal inside your network | Your own virtual machines, containers or bare metal inside your network | Inside the AWS account and VPC you control, as a managed service |
| Who operates it | Your platform or network team, including patching and failover of the balancer itself | Your platform or network team, including patching and failover of the balancer itself | AWS operates the service, while your team owns configuration, target groups and monitoring |
| What the team must maintain | Configuration files, TLS-related settings if any, redundant balancer pairs and upgrades | Configuration files, stream module settings, redundant balancer pairs and upgrades | Listeners, target groups, health check settings and access policies within your AWS account |
| Fit for the choice | Suits on-premises or multi-cloud estates with existing HAProxy skills | Suits teams already running NGINX who accept the TCP stream configuration | Suits clusters already hosted on AWS where a managed Layer 4 service is preferred |
Configuring the load balancer step by step
This sequence puts an external TCP load balancer in front of a Security Server cluster so that message exchange and OCSP traffic reach healthy nodes and fail over without terminating TLS. Each step ends with a check you can run before moving on.
Confirm ports 5500 and 5577 reach the cluster
Run this check from a host on the external network that consumers and providers use. Confirm that TCP 5500 (message exchange) and TCP 5577 (OCSP) reach the virtual address in front of the cluster and that firewall rules on every Security Server allow traffic from the balancer. Use a TCP connect test such as
nc -vzagainst both ports. The step is done when both ports connect from outside and any port you did not open is refused. Port requirements are listed in the Security Server installation guide.Create TCP listeners that pass TLS through
Create one TCP listener per port with no TLS termination, so the balancer forwards encrypted bytes unchanged and each Security Server keeps its own certificates. Illustrative HAProxy block for port 5500:
frontend xroad_msgwithmode tcp,bind :5500anddefault_backend xroad_msg_nodes, then a backend withmode tcpand oneserverline per node withcheck. Illustrative NGINX stream block:upstream xroad_msglisting each node on port 5500, andserver { listen 5500; proxy_pass xroad_msg; }. In AWS NLB, use a TCP listener (not TLS) on 5500 forwarding to a target group with protocol TCP. Verify by checking that the certificate presented on the balancer address matches a node certificate, not a balancer certificate.Point health checks at the health endpoint
Enable the Security Server health check endpoint on each node and confirm its path and port for your X-Road version in the health check documentation, because this plan does not assume a default. In HAProxy, add the endpoint with
option httpchkand mark servers withcheck port <health-port>. Open-source NGINX stream uses passive checks throughmax_failsandfail_timeoutunless your edition supports active checks, so confirm what your build offers. In AWS NLB, set the target group health check to the health port and the protocol the endpoint supports. The check is complete when each node reports healthy and a stopped node reports unhealthy.Register every node in the balancer pool
Add each Security Server to the backend pool for both ports, using the addresses that the balancer can reach on the internal network. Keep the node list identical across ports so that message exchange and OCSP use the same set of servers. In HAProxy,
show staton the admin socket lists each server as UP. In AWS NLB, the target group health view should show every registered target as healthy. Record the node list in your change record, since the cluster design depends on every node holding the same configuration and certificates.Test message exchange through the balancer
From a consumer system, send test service calls to the balancer address and confirm they succeed. Repeat several calls and check the logs on each node to confirm that traffic is spread across the pool. Also confirm OCSP responses are returned through port 5577. Ask your platform team which node logs show message traffic for your version, since log locations and fields differ by release. The step is done when calls succeed through the balancer and each node that is healthy receives traffic.
Test failover by stopping one node
Stop the Security Server service on one node, or block its ports at the host firewall, and watch the balancer mark it as down within the health check interval. Send test calls during the outage and confirm they still succeed through the remaining nodes. Restore the node and confirm it returns to healthy and receives traffic again. Messages being processed on the failed node at the moment it stopped may be lost, so repeat the test with the retry behavior your consumers use. Record the observed removal and rejoin times as your baseline.
Worked configuration examples for each platform
HAProxy is a common choice for TCP-level balancing because its mode tcp setting forwards the TLS session without terminating it, which keeps the Security Server certificates and client authentication on the nodes themselves. The example below is illustrative only. Replace the addresses with your Security Server node IPs and confirm the health check path against the health check service page before use.
- Passthrough mode: Set
mode tcpon the frontend and backend so HAProxy does not inspect or terminate TLS for message exchange on port 5500. - Frontend binding: Bind the frontend to the external address on TCP 5500 and point it at a backend named for the cluster.
- Health checks: Use
option httpchkwith the health check path from the health check service page, and setcheckon eachserverline with an interval and rise and fall thresholds. - OCSP port: Repeat the pattern for TCP 5577 with a separate frontend and backend if OCSP responses are also served through the balancer.
- Stickiness: Decide whether source-based stickiness is needed and test it, because the cluster design determines how requests should be distributed.
Before going live, confirm that the health check endpoint is reachable from the balancer network and that a node removed from the pool stops receiving traffic.
NGINX balances TCP traffic through its stream module, which sits beside the HTTP context and is separate from it. Passthrough works because the stream block forwards bytes without decrypting them. The example below is illustrative. The stream module must be available in your NGINX build, and the upstream health behavior depends on the NGINX edition and version you run, so confirm both in your environment.
- Stream block: Define an
upstreamgroup with the Security Server node addresses on port 5500 and aserverblock in thestreamcontext that proxies to it. - Passive checks: Use
max_failsandfail_timeouton each upstream member to take a failing node out of rotation after repeated connection errors. - Active checks: Active health checks are not part of every open-source build, so verify whether your version supports them or use the health check endpoint through an external monitor.
- Balancing method: Choose the method deliberately, for example the default round robin or
hashon the client address when you need consistent routing. - Separate ports: Declare a second
serverblock for TCP 5577 if OCSP traffic runs through the same balancer.
Check that the stream configuration loads with a syntax test and that a failed node is removed from the upstream group in a controlled test.
The AWS Network Load Balancer works at Layer 4, so it forwards TCP connections to targets without reading the TLS session. You configure it with a listener, a target group and a health check, all managed through AWS. The settings below are illustrative. Confirm the health check protocol, path and port against the health check service page, and confirm current NLB limits and options in the AWS documentation.
- Listener: Create a TCP listener on port 5500 that forwards to a target group containing the Security Server instances.
- Target group protocol: Set the target group to TCP on port 5500 so traffic passes through unchanged, and check whether your design needs a separate target group for port 5577.
- Health check: Choose the protocol and path that the health check service exposes, and set the interval, healthy and unhealthy thresholds to values your team has tested.
- Client address handling: Review how source addresses reach the Security Server nodes, because access controls and logs on the nodes depend on it.
- Network placement: Place the NLB and targets in subnets and security groups that allow the message exchange and OCSP ports from external networks and the health check traffic.
Verify that the target group reports nodes as healthy only when the health check service confirms them, and that a node failure removes it from the group within the timing you expect.
The three examples differ in where the configuration lives and who operates it. HAProxy and NGINX are files you manage on your own hosts, while the NLB is configured through AWS and billed as a managed service. The table of choices is a planning aid: test each option against your network design, your monitoring and the way your team handles changes before you commit to one.
- Configuration ownership: HAProxy and NGINX configurations sit in your change management process, while NLB settings are changed through the AWS console, API or infrastructure-as-code tooling.
- Health check fidelity: Confirm which health check types each option supports in your version and how it reports failures to your operators.
- Failover testing: Stop one Security Server node during a test window and confirm that new connections go to the remaining nodes and that existing traffic behaves as your design expects.
- Logging: Decide where balancer logs are stored and whether they can be correlated with Security Server logs during an investigation.
- Ports: Verify that message exchange, OCSP and the admin and information system ports are handled as intended, since only some of them should face external networks.
Ask your balancer vendor or cloud provider to confirm current behavior for passthrough and health checks before finalizing the design.
Security considerations for TLS passthrough and admin access
A TCP-level balancer in front of a Security Server cluster sees encrypted traffic and little else, so the security work shifts to what the balancer can reach, what it logs, and who can change it. The cards below cover the decisions that keep certificate handling on the Security Servers and keep the admin interface off the balancer.
Certificates stay on the Security Servers
With TLS passthrough, the balancer forwards the TLS session on TCP 5500 without terminating it, so the handshake and the member authentication certificates are handled by each Security Server. The balancer never holds a private key for exchanged messages. Confirm that the listener is a TCP listener in every configuration you build, because an HTTPS listener with certificate termination would move that trust decision to the balancer and change the design.
Hardening guideNever expose the admin UI
The Security Server admin UI listens on TCP 4000 and is meant for internal administrators only. Do not add a listener, target group or backend rule for port 4000 on the balancer, and do not let a generic catch-all rule forward it. Review the balancer configuration against the internal port list in the installation guide before each change. The admin interface should be reached through a separate, restricted path such as a management network or bastion.
Installation guideSource address handling
Under passthrough, the Security Server sees the balancer's address as the source of the TCP connection, not the consumer's. Client address logic and allow lists built on the source IP must account for this. Confirm which source address the balancer uses for health checks and for forwarded traffic, and whether your network allows return traffic from each Security Server to the original client. Test with a real consumer path before go-live.
What the balancer can see in logs
A layer 4 balancer records connection-level data such as source address, destination port, timestamps and byte counts. It cannot read request paths, member identifiers or message content inside the TLS session. Do not assume the balancer log will support an investigation of an exchanged message. The X-Road message log on each Security Server is the record of exchanged messages, so confirm where each log is kept, how long it is retained and who can read it.
Access control for the balancer
The balancer controls which Security Servers receive traffic, so changes to its configuration are security changes. Limit administrative access with named accounts, key-based SSH where it applies, and a separate change approval step. Keep its configuration in version control, restrict who can edit health check and backend lists, and monitor for unexpected backends. Ask your vendor or cloud provider which management interfaces and API permissions the balancer exposes.
Why health checks decide how fast failed nodes leave rotation
The health check settings decide how long a failed Security Server keeps receiving traffic. A load balancer does not know a node has failed until its probe says so, and the time it takes to act on that result is set by three things: how often it probes (the interval), how long it waits for an answer before counting the probe as failed (the timeout), and how many consecutive failures it requires before removing the node (the failure threshold). A short interval with a low threshold removes a dead node quickly, but it also removes a node that is merely slow for a moment. A long interval with a high threshold avoids that flapping, at the cost of sending message exchange traffic to a node that is already down for longer. Each of these values has to be set for the specific Security Server cluster, not copied from a generic example.
The probe itself matters as much as the timing. The health check service for Security Servers is the endpoint the balancer should call, and the reader should confirm in the health check service documentation exactly what the endpoint reports, which status codes it returns when a dependency such as the database is unavailable, and whether a slow response is distinguished from a failed one. A node can answer its probe while message exchange on port 5500 is failing, so the health check result is only as useful as its coverage. Plan to confirm this by stopping the database or the Security Server service on a test node and measuring how long the balancer takes to stop sending it traffic.
Test the settings under realistic load before go-live, and then again after each X-Road upgrade, because a release can change response times. Record the removal time, the time to restore a recovered node, and whether any node oscillates between in and out of rotation during a brief network interruption. If a node flaps, lengthen the threshold or timeout before shortening the interval. Document the final values with the balancer configuration so operations staff know the expected failover window when an incident occurs.
Limits to confirm before relying on a load balancer
A load balancer spreads Security Server traffic across nodes, but it does not make the cluster itself safe to operate. The cards below cover what the balancer leaves untouched, what can be lost on failure, and what to confirm with NIIS documentation and your own environment before go-live.
Configuration and keys stay per node
The balancer only forwards TCP connections. It does not copy the serverconf database, signing keys, certificates or configuration files between nodes. Each node must be kept in step by the cluster design itself, so a change made on one node is not automatically visible on the others. Check how configuration reaches secondaries and how you verify that all nodes present identical keys and certificates before you rely on the balancer for failover.
In-flight messages can be lost
If a node fails while it is processing a request, the balancer can route the retry to a healthy node, but the original message may already be lost. The balancer cannot tell whether the upstream system completed the exchange. Ask NIIS and your integration partners how retries, duplicates and timeouts are expected to behave, and confirm that your information systems can handle a resend safely.
The balancer is a single point of failure
One balancer in front of a healthy cluster simply moves the single point of failure to a different box. Plan a second balancer with a floating address, a managed load balancer with its own redundancy, or DNS that fails over, and test the failover path. Confirm the availability design of the chosen product with its vendor, since the balancer's own failure mode determines the real availability of the exchange.
Confirm supported products and modes
Whether haproxy, nginx, AWS Network Load Balancer or another product is supported for a given Security Server version, and in which passthrough mode, has to be confirmed against NIIS documentation before deployment. Do not assume that a configuration working in a lab is a supported configuration. Record the exact product version, the mode and the Security Server release in your change documentation, and confirm them again before each upgrade.
Security Server installation guideConfirm ports and the target environment
The Security Server listens on TCP 5500 for message exchange and 5577 for OCSP from external networks, and on TCP 4000 for the admin UI. The balancer must forward only the ports that its clients need and must reach the nodes on the correct ports. Check the firewall and security group rules in your target environment, including health check traffic, and confirm that the admin interface is not exposed through the balancer.
Questions buyers ask about load balancing X-Road
Can TLS be terminated at the load balancer for X-Road Security Servers?
Generally, no. The Security Server exchanges messages over mutually authenticated TLS between members, and the client certificate and member identity must reach the Security Server intact, so the balancer should pass TCP traffic through without decrypting it. Terminating TLS at the balancer would move the trust decision out of the Security Server and break the identity checks that X-Road depends on. TLS passthrough at layer 4 keeps the handshake between the two members. Confirm the exact behavior of your chosen balancer and the port set you expose (TCP 5500 for message exchange and 5577 for OCSP from external networks) with your security architect before the design is approved.
What skills and effort does a load balancer setup for X-Road need?
The work needs people who understand Linux networking, TCP load balancing, TLS passthrough, health checks and firewall rules, plus enough X-Road knowledge to know which ports and paths the Security Server uses. The effort depends on how many nodes sit behind the balancer, whether you manage the balancer as code, and how much monitoring and failover testing you require. Your team should be able to read the balancer configuration, reproduce a node failure in a test environment, and explain which traffic is passed through and which is blocked. Ask any partner to show how they validate each of these before handover.
Can our own team set up the load balancer internally?
Often yes, if your team already operates load balancers and has access to a staging copy of the X-Road cluster. The harder parts are usually not the balancer syntax but the interaction with the Security Server cluster: keeping configuration identical across nodes, choosing a health check that reflects real readiness, and testing failover without disrupting live exchanges. An internal team should decide early whether it has the time and on-call coverage to own those tests. A fixed-scope engagement with DeployOpen can cover planning, configuration for your chosen product, and written test evidence, while your team keeps operational ownership.
How long does testing a load balancer for X-Road take?
The duration depends on the environment, not on a single fixed number. Testing time grows with the number of nodes and load balancer types, the number of connected information systems, the variety of client certificates and ports in use, and whether you need to test node failure, recovery and maintenance drains. Test environments that mirror production networking, firewalls and certificates take longer to prepare than lab setups. Ask any provider for a written test plan listing each scenario, the environment it runs in and the evidence it produces, and then judge the timeline against that plan.
What does DeployOpen need from our team to start the work?
DeployOpen needs enough information to write a fixed scope: the X-Road version in use (the current release is 7.8.3, with 7.7.4 and 7.6.5 also supported), the number of Security Server nodes, the balancer you intend to use (HAProxy, NGINX or AWS Network Load Balancer), the network zones and firewall rules between them, and the health check endpoint you plan to enable. You should also provide access to a test environment, named contacts for network and security decisions, and your change approval process. Any gap in these inputs typically shows up as extra design time during the engagement.
How is a load balancer setup for X-Road priced?
DeployOpen works from a written scope, so the quote reflects the agreed deliverables rather than a standard price list. The main cost drivers are the number of nodes and balancers, the chosen product, the number of environments that need testing, the amount of health check and failover validation required, and whether you want ongoing support or a handover only. Ask for a quote that separates design, configuration, testing, documentation and knowledge transfer, and states which items are one-time and which recur, such as retainer support or re-testing after upgrades.
Does a load balancer remove the need for X-Road clustering planning?
No. A load balancer distributes incoming connections across Security Servers, but it does not copy configuration, keys or the serverconf database between them. Those requirements are covered by the cluster design, and the balancer only controls where traffic goes. Plan the cluster and the balancer together, and confirm with the X-Road documentation and your architects which failures the design protects against and which it does not.
Which X-Road versions and platforms this setup applies to
The configuration in this topic applies to the Security Server of the X-Road release line your organization runs. The supported release lines are 7.8.3, 7.7.4 and 7.6.5, and 7.8.3 is the current release. Confirm which of these your member runs before you copy any example, because the load balancer must match the Security Server behavior of that exact version, including how the admin UI and the health check endpoint respond. Check the release notes for the version you run, and record the version in the change ticket for the cluster so that a later upgrade does not invalidate the load balancer settings.
The Security Server is supported on Ubuntu Server 22.04 and 24.04 LTS on x86-64, and on Red Hat Enterprise Linux 8 and 9. Each node in the cluster should run the same operating system family and version, so that the TLS libraries, network stack defaults and PostgreSQL client behavior are identical across primary and secondaries. The installation guide also lists a minimum of 3 GB RAM (4 GB with monitoring add-ons) and 3 GB free disk space per node. Your load balancer tests should run on the same network path that real consumers and producers use, since the balancer is only one hop in the traffic path.
X-Road 8 "Spaceship" is available as 8.0.0 Beta 2, and its production release is scheduled for December 2026. It is a different platform, so do not assume that HAProxy, nginx or NLB settings written for 7.x carry over. Treat any X-Road 8 work as a separate evaluation in a non-production environment, and plan to revalidate your load balancer design against the 8.x release notes when that release is generally available. Until then, the settings in this topic are for X-Road 7.x Security Servers only.
How DeployOpen works on this
DeployOpen plans, builds, documents and supports self-hosted open-source platforms inside your own infrastructure, including the load balancer in front of an X-Road Security Server cluster. The work starts with a written scope that fixes the balancer choice, health check behavior and TLS handling before any configuration is changed.
How we scope
- Confirm which balancer your team will operate: haproxy, nginx, or AWS Network Load Balancer, with the reasons tied to your network.
- Map which Security Server ports reach the balancer from external networks and which stay internal, including the admin and information system paths.
- Agree in writing whether TLS passes through to the Security Servers unchanged and who owns certificate renewal and rotation.
How we build
- Configure TCP-level listeners and backend pools for the message exchange and OCSP ports in a lab that mirrors your cluster.
- Wire the health check endpoint into the balancer so failed nodes leave rotation, then tune thresholds with your team against real failure tests.
- Test failover by stopping a node, reviewing session behavior and confirming that retried requests from consumers reach a healthy member.
How we hand over
- Deliver versioned configuration files for your chosen balancer, with the parameters documented and the reasoning for each setting recorded.
- Provide a runbook covering node removal, re-adding a node, and balancer restarts, written for the engineers who will run it.
- Walk your operations team through the failover test results and the open items that remain outside the balancer, such as configuration sync.
How we support
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts. A quote follows from that scope.
- Ongoing support, upgrades of the balancer and the Security Server release, and continuous testing are available as retainers.
- Ask us to confirm the supported X-Road release line and balancer versions for your environment before the build begins.

