Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
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.
Pre-setting
- HAProxy and cluster servers must be on the same network.
- The firewall must be configured to work with PAM and PAM Core Gateway, or disabled.
To disable the firewall, use the command
Code Block language bash theme RDark $ sudo ufw disable
To open the ports, use the command:
Code Block language bash theme RDark $ sudo ufw enable $ sudo ufw allow 80 $ sudo ufw allow 443 $ sudo ufw allow 3389 $ sudo ufw allow 8084
HAProxy 1.8-stable (LTS) setup
Update the operating system using the commands:
Code Block language bash theme RDark $ sudo apt update $ sudo apt upgrade
Install HAProxy using the command:
Code Block language bash theme RDark $ 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:
Code Block language bash theme RDark $ sudo nano /etc/default/haproxy
then append to the end of file ENABLED=1:
Code Block language bash title содержимое файла /etc/default/haproxy # 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:
Code Block language bash theme RDark $ sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig
To change the configuration of HAProxy with the following command:
Code Block language bash theme RDark $ sudo nano /etc/haproxy/haproxy.cfg
and edit the settings.
To check the correctness of the configuration file enter the command:
Code Block language bash theme RDark $ haproxy -c -f /etc/haproxy/haproxy.cfg
To restart the service after editing the configuration HAProxy with the following command:
Code Block language bash theme RDark $ systemctl restart haproxy