Haproxy. RDP Balancing
Версия от 16:23, 23 августа 2022; Cless (обсуждение | вклад) (Новая страница: «== Links == [https://habr.com/ru/post/503430/https://habr.com/ru/post/335872/https://kuzevanov.ru/linux/%D0%BE%D1%81%D0%BD%D0%BE%D0%B2%D1%8B-%D1%80%D0%B0%D0%B1%D0...»)
Links
https://habr.com/ru/post/503430/
https://habr.com/ru/post/335872/
Description
Balancing rdp clients via haproxy (RDP) to several RDP server
Installation
User (Client RDP) ↓ Internet ↓ HAProxy (RDP) ↓ ↓ RDP Server1 RDP Server2 ↓ ↓ DATABASE
yum install haproxy
cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.ORIG
nano /etc/haproxy/haproxy.cfg
#--------------------------------------------------------------------- # Global settings #--------------------------------------------------------------------- global # to have these messages end up in /var/log/haproxy.log you will # need to: # # 1) configure syslog to accept network log events. This is done # by adding the '-r' option to the SYSLOGD_OPTIONS in # /etc/sysconfig/syslog # # 2) configure local2 events to go to the /var/log/haproxy.log # file. A line like the following can be added to # /etc/sysconfig/syslog # # local2.* /var/log/haproxy.log # log 127.0.0.1 local2 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 4000 user haproxy group haproxy daemon # turn on stats unix socket stats socket /var/lib/haproxy/stats #--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults mode http log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 ##### frontend fr_rdp mode tcp # LISTEN RDP PORT OF HAPROXY SERVER bind *:3389 name rdp log global option tcplog tcp-request inspect-delay 2s tcp-request content accept if RDP_COOKIE default_backend BK_RDP backend BK_RDP mode tcp balance leastconn timeout server 5s timeout connect 4s log global option tcplog stick-table type string len 32 size 10k expire 8h ### TABLE WITH USERS DEPENDS ON USERNAME IN rdp_cookie OF CLIENT stick on rdp_cookie(mstshash) ### -OR- ### TABLE WITH USERS DEPENDS ON src-ip OF CLIENT # stick on src option tcp-check tcp-check connect port 3389 default-server inter 3s rise 2 fall 3 # SERVERS RDP FOR BALANCING server TS01 192.168.199.36:3389 weight 10 check server TS02 192.168.199.37:3389 weight 20 check listen stats bind *:9000 mode http stats enable #stats hide-version stats show-node stats realm Haproxy\ Statistics stats uri /
systemctl restart haproxy
systemctl status haproxy