You need to load balance Microsoft Terminal Services or remoteapps. Both of them use the RDP protocol. One main issue when using RDP is to be able to stick a user to a server. The configuration below shows you how to build outage-free Terminal server infrastructure with ALOHA and HAProxy.


The TSE infrastructure looks like the image below:


Basically, we have a couple of ALOHA load balancers in active/passive mode. The ALOHAs share a VIP,, on which clients will get connected. In order to ensure stickiness, the ALOHAs will use the RDP cookie and store it in a table where it is associated with the server serving the request. Finally, this table is shared between both ALOHAs in order to ensure safe failover.


Find below the configuration for such infrastructure:

peers aloha
  peer aloha1
  peer aloha2

# RDP / TSE configuration
frontend ft_rdp
 mode tcp
 bind name rdp
 timeout client 1h
 option tcpka
 option tcplog
 log global
 # wait up to 5s for an RDP cookie in the request
 tcp-request inspect-delay 5s
 tcp-request content accept if RDP_COOKIE
 default_backend bk_rdp

backend bk_rdp
 mode tcp
 balance rdp-cookie
 persist rdp-cookie

 # Options
 timeout server 1h
 timeout connect 4s
 option redispatch
 option tcpka
 option tcplog
 log global

  # sticky persistence
  stick-table type string len 32 size 10k expire 1d peers aloha
  stick on rdp_cookie(mstshash)

  # Server farm
  server tse1 weight 10 check inter 2s rise 2 fall 3
  server tse2 weight 10 check inter 2s rise 2 fall 3
  server tse3 weight 10 check inter 2s rise 2 fall 3
  server tse4 weight 10 check inter 2s rise 2 fall 3

Now, the users can point their RDP client to the VIP and get load-balanced. In case of a client-side network outage or ALOHA failover, users will keep on being redirected to the same server. The users won’t suffer any application outages.


Subscribe to our blog. Get the latest release updates, tutorials, and deep-dives from HAProxy experts.