HAProxy Enterprise
This section describes how to install the Data Plane API on HAProxy Enterprise.
Run the API as a Systemd service
You can enable the Data Plane API as a Systemd service.
-
Install the Data Plane API package:
For Data Plane API version 2.5:
$ # On Debian/Ubuntu $ sudo apt-get install hapee-extras-dataplaneapi25
$ # On CentOS/RedHat/Oracle $ sudo yum install hapee-extras-dataplaneapi25
$ # On SUSE $ sudo zypper install hapee-extras-dataplaneapi25
$ # On FreeBSD $ sudo pkg install hapee-extras-dataplaneapi25
This adds the program here: /opt/hapee-extras/sbin/hapee-dataplaneapi.
-
Add a
userlist
section to your configuration file, /etc/hapee-1.9/hapee-lb.cfg, that sets a username and password to require when calling API functions.In the example below, we add a user named admin with the password adminpwd:
userlist hapee-dataplaneapi user
admininsecure-passwordadminpwdOptionally, first encrypt the password with the
mkpasswd
command from the whois package:$ sudo apt install -y whois $ mkpasswd -m sha-256 mypassword # encrypted password displayed
Then copy and paste the encrypted password into your configuration file:
userlist hapee-dataplaneapi user
adminpassword$5$aVnIFECJ$2QYP64eTTXZ1grSjwwdoQxK/AP8kcOflEO1Q5fc.5aA -
Be sure that your configuration has a
stats socket
line in theglobal
section. This enables the Runtime API, which the Data Plane API uses to make some changes without requiring a reload.global stats socket
/var/run/hapee-1.9/hapee-lb.sockuser hapee-lb group hapee mode 660 level admin expose-fd listeners -
Enable and start the service:
$ sudo systemctl enable hapee-extras-dataplaneapi $ sudo systemctl start hapee-extras-dataplaneapi
Choose a different IP address and port
By default, the API listens on all IP addresses at port 5555. You can change this by editing the file /etc/hapee-extras/dataplaneapi.hcl.
-
Change the
host
and/orport
fields in thedataplaneapi
block.dataplaneapi { host = "192.168.50.20" port = 5557
Alternatively, set the $HOST and $PORT environment variables.
-
Restart the service:
$ sudo systemctl restart hapee-extras-dataplaneapi
Verify that the API works
-
Verify that the API is running properly by calling the info function:
$ curl -X GET --user admin:adminpwd http://localhost:5555/v2/info {"api":{"build_date":"2020-11-10T14:37:06.000Z","version":"v2.1.0-ee6 30a03a6.dirty"},"system":{}}
If you get this error:
{"code":500,"message":"dial unix /var/run/hapee-1.9/hapee-lb.sock: connect: permission denied"}
This means that the user who runs the API does not have access to the Runtime API socket. Check that you added them to the system group hapee, log out and back in again, then try it again.
Next up
CLI