Load balancing is performed using HAProxy.
HAProxy is a server application for providing high availability and load balancing for TCP and HTTP applications by distributing incoming requests to several serving servers. Available for Linux, FreeBSD, OpenBSD, Solaris (8/9/10), AIX (5.1–5.3), macOS, Cygwin.
To disable the firewall, use the command
$ sudo ufw disable |
To open the ports, use the command:
$ sudo ufw enable $ sudo ufw allow 80 $ sudo ufw allow 443 $ sudo ufw allow 3389 $ sudo ufw allow 8084 |
Update the operating system using the commands:
$ sudo apt update $ sudo apt upgrade |
Install HAProxy using the command:
$ sudo add-apt-repository ppa:vbernat/haproxy-1.8 $ sudo apt update $ sudo apt install haproxy |
Configure HAproxy to start automatically after server reboot. Open the configuration file with the command:
$ sudo nano /etc/default/haproxy |
then append to the end of file ENABLED=1:
# Defaults file for HAProxy # # This is sourced by both, the initscript and the systemd unit file, so do not # treat it as a shell script fragment. # Change the config file location if needed #CONFIG="/etc/haproxy/haproxy.cfg" # Add extra flags here, see haproxy(1) for a few options #EXTRAOPTS="-de -m 16" ENABLED=1 |
Save a backup copy of the configuration file HAProxy with the command:
$ sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig |
To change the configuration of HAProxy with the following command:
$ sudo nano /etc/haproxy/haproxy.cfg |
and edit the settings.
To check the correctness of the configuration file enter the command:
$ haproxy -c -f /etc/haproxy/haproxy.cfg |
To restart the service after editing the configuration HAProxy with the following command:
$ systemctl restart haproxy |