HAProxy 1.9.0 Porting Guide (openEuler 20.03 LTS SP1)

randy15682021-12-29HAProxyPorting Guide



HAProxy is a free and open-source software program written in C. It provides a high availability load balancer and proxy server for TCP and HTTP-based applications, supports virtual hosts, and has a reputation for being fast and reliable. Programming language: C

Brief description: web load balancer

HAProxy 1.9.0


This document applies to HAProxy 1.9.0. However, you can refer to this document when porting other HAProxy versions.

Environment Requirements


ServerTaiShan 200 server (model 2280)
CPUKunpeng 920 5250 processor
Drive partitionNo requirements


openEuler20.03 LTS SP1 AArch64

Check the current system information.

cat /etc/os-release

For details about how to install the openEuler OS, see https://docs.openeuler.org/en/docs/20.03_LTS_SP1/docs/Installation/Installation.html.
Notes: You are advised to select the "Server with GUI" installation mode.

Installing HAProxy Using the RPM Package Obtained from a Mirror Site

If your server can access the network, run the "wget https://mirrors.huaweicloud.com/kunpeng/yum/el/7/aarch64/Packages/web/haproxy-1.9.0-1.el7.aarch64.rpm" command to download the RPM package. Otherwise, visit https://mirrors.huaweicloud.com/kunpeng/yum/el/7/aarch64/Packages/web/haproxy-1.9.0-1.el7.aarch64.rpm to download the package and copy it to the /home directory on the server.

Notes: The RPM packages in the mirror site are compiled and packaged using open-source code, and then uploaded to the mirror site.

The following describes how to download the RPM package to the local PC and then upload it to the server.

  1. Install HAProxy.

    rpm -ivh haproxy-1.9.0-1.el7.aarch64.rpm
  2. View the installation directory.

    ls /usr/local/haproxy

Operation and Verification

  • Configure parameters.

    a. Open the option-http_proxy.cfg file.

    vi  /usr/local/haproxy/conf/option-http_proxy.cfg

    b. Modify the file as follows, and save and close the file:

    maxconn      20000
    log      local0  info
    uid               0
    gid               0
    chroot          /usr/local/haproxy
    nbproc          4
    mode                       http
    retries                      3
    timeout connect      10s
    timeout client          20s
    timeout server         30s
    timeout check          2s
    frontend test-proxy
    bind            *:80
    mode            http
    log             global
    default_backend test-proxy-srv
    backend test-proxy-srv
    balance        roundrobin
    option http-server-close
    option httpchk   GET /index.html
    http-check expect       status 200
    server          web1    IP1:PORT1 weight 3
    server          web2    IP2:PORT2 weight 3

    For details about the parameters in the configuration file, see the following table.

maxconn 20000Specifies the maximum number of connections.
log local0 infoSpecifies the log output device. info indicates the log severity level.
uid 0Specifies the ID of the user who runs HAProxy.
gid 0Specifies the ID of the user group to which the user running HAProxy belongs.
chroot /usr/local/haproxySpecifies the chroot running path.
nbproc 4Specifies the number of processes.
daemonRuns HAProxy in the background.
mode httpSpecifies the processed type (layer 7 uses HTTP, and layer 4 uses TCP).
retries 3Specifies the maximum number of retries for connecting to the backend server. If the number of retries exceeds the specified value, the backend server is unavailable.
timeout connect 10sSpecifies the maximum time allowed before the connection between HAProxy and the backend server is set up.
timeout client 20sSpecifies the timeout period for keeping an idle connection with the client.
timeout server 30sSpecifies the timeout period for keeping an idle connection with the server.
timeout check 2sSpecifies the timeout period for checking the server.
frontend test-proxy-
bind *:80Specifies one or more listening sockets. The asterisk (*) indicates all IPv4 addresses.
mode httpSpecifies the processed type (layer 7 uses HTTP, and layer 4 uses TCP).
log globalInherits the definition of log in the global section.
default_backend test-proxy-srvSpecifies the default backend server pool.
backend test-proxy-srv-
balance roundrobinSpecifies the load balancing algorithm round robin, which is a weight-based polling algorithm and applies to scenarios where servers have roughly identical performance.
option http-server-This parameter must be enabled when the persistent connection is enabled.
option httpchk GET /index.htmlhttp-check expect status 200Enables HTTP service status check (health check) and checks the returned status code. If "200" is not returned, no request is sent to backend servers.
server web1IP1:PORT1 weight 3 server web2 IP2:PORT2 weight 3Defines multiple backend servers. Format: server :[port] [param*]** (Note: **IP1:PORT1 and IP2:PORT2 indicate the IP address and port number of a backend server.)
  • Start HAProxy.

    taskset -c 0-3 /usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/conf/option-http_proxy.cfg
  • Verify HAProxy.

    ps -ef | grep haproxy

    The HAProxy process is displayed.

    Open the browser, enter http://HAProxy IP address:80 in the address box, and press Enter. The WebUI page of the backend server is displayed, indicating that HAProxy is running properly. Refresh the page. The page switches between backend servers.


    • (Optional) Stop HAProxy. Do not run this command when services are running.

      pkill haproxy
    • (Optional) Uninstall HAProxy and query the result.

      rpm -qa | grep haproxy
      rpm -e --nodeps haproxy-1.9.0
      rpm -qa | grep haproxy
      rm -rf /usr/local/haproxy

[Disclaimer] This article only represents the author's opinions, and is irrelevant to this website. This website is neutral in terms of the statements and opinions in this article, and does not provide any express or implied warranty of accuracy, reliability, or completeness of the contents contained therein. This article is for readers' reference only, and all legal responsibilities arising therefrom are borne by the reader himself.