Synopsis

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 you can build outage-free Terminal server infrastructure thanks to the Aloha and HAProxy.

Diagram

The TSE infrasctructure looks like the image below:
rdp infrastructure

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

Configuration

find below the configuration for such infrastructure:
[sourcecode language=”text”]
peers aloha
peer aloha1 10.0.0.16:1024
peer aloha2 10.0.0.17:1024

# RDP / TSE configuration
frontend ft_rdp
mode tcp
bind 10.0.0.18:3389 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 10.0.0.23:3389 weight 10 check inter 2s rise 2 fall 3
server tse2 10.0.0.24:3389 weight 10 check inter 2s rise 2 fall 3
server tse3 10.0.0.25:3389 weight 10 check inter 2s rise 2 fall 3
server tse4 10.0.0.26:3389 weight 10 check inter 2s rise 2 fall 3
[/sourcecode]

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

Links