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

  1. HAProxy and cluster servers must be on the same network.
  2. The firewall must be configured to work with PAM and PAM Core Gateway, or disabled.
    1. To disable the firewall, use the command

      Code Block
      languagebash
      themeRDark
      $ sudo ufw disable


    2. To open the ports, use the command:

      Code Block
      languagebash
      themeRDark
      $ 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

  1. Update the operating system using the commands:

    Code Block
    languagebash
    themeRDark
    $ sudo apt update
    $ sudo apt upgrade


  2.  Install HAProxy using the command:

    Code Block
    languagebash
    themeRDark
    $ sudo add-apt-repository ppa:vbernat/haproxy-1.8
    $ sudo apt update
    $ sudo apt install haproxy


  3.  Configure HAproxy to start automatically after server reboot. Open the configuration file with the command:

    Code Block
    languagebash
    themeRDark
    $ sudo nano /etc/default/haproxy

    then append to the end of file ENABLED=1:

    Code Block
    languagebash
    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


  4. Save a backup copy of the configuration file HAProxy with the command:

    Code Block
    languagebash
    themeRDark
    $ sudo cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.orig


  5. To change the configuration of HAProxy with the following command:

    Code Block
    languagebash
    themeRDark
    $ sudo nano /etc/haproxy/haproxy.cfg

    and edit the settings.

  6. To check the correctness of the configuration file enter the command:

    Code Block
    languagebash
    themeRDark
    $ haproxy -c -f /etc/haproxy/haproxy.cfg


  7. To restart the service after editing the configuration HAProxy with the following command:

    Code Block
    languagebash
    themeRDark
    $ systemctl restart haproxy