SFTP configuration through HAProxy loadbalancing

haproxyload balancingsftp

I have LB server which currently load balancing 2 machines as for apache2 "http" and "https" requests as master/slave,

How to make the same server load balancing "sftp" requests to the same both machines using default port "22"?

frontend ft_app
        bind 1.1.1.1:80
        reqadd X-Forwarded-Proto:\ http
        default_backend bk_app

frontend ft_apps
        bind 1.1.1.1:443 ssl crt /etc/ssl/certs/bundle.pem ca-file /etc/ssl/certs/cert.cer verify optional
        reqadd X-Forwarded-Proto:\ https
        default_backend bk_apps

backend bk_app
        server server1 2.2.2.2:80 check
        server server2 3.3.3.3:80 check backup

backend bk_apps
        server servers1 2.2.2.2:443 ssl check verify none
        server servers2 3.3.3.3:443 ssl check verify none backup

Best Answer

You might try using the following for the backend SFTP servers:

listen frontend_ssh 1.1.1.1:22
        mode tcp
        option tcplog
        balance roundrobin
        server server1 2.2.2.2:22
        server server2 3.3.3.3:22

I based the above on this post: http://jpmorris-iso.blogspot.com/2013/01/load-balancing-openssh-sftp-with-haproxy.html

Hope this helps