HAProxy Enterprise Documentation 2.2r1

Install the HAProxy Enterprise Runtime API

This page describes how to enable and then access the HAProxy Enterprise Runtime API.

Enable the Runtime API

To enable the Runtime API, add a stats socket directive to the global section of your configuration. You can expose the API as either a UNIX socket, in which case you can access it only from the HAProxy Enterprise server, or as an IP address and port, in which case you can access it remotely.

To configure it as a UNIX socket, set the path where you would like the socket to be created, such as /var/run/hapee-2.2/hapee-lb.sock.

   stats socket /var/run/hapee-2.2/hapee-lb.sock  user hapee-lb  group hapee  mode 660  level admin  expose-fd listeners

Or set an IP address and port:

   stats socket ipv4@  level admin  expose-fd listeners

You can set the IP address to an asterisk to listen on all network interfaces.

   stats socket ipv4@*:9999  level admin  expose-fd listeners

The parameters are as follows:




Sets the owner of the UNIX socket to the designated system user.


Sets the group of the UNIX socket to the designated system group.


Sets the octal mode used to define permissions on the UNIX socket.


Restricts the commands that you can be issued. Set it to one of the following values:

  • user - only non-sensitive stats can be read and no changes are allowed.

  • operator - [default] all data can be read and non-sensitive changes are allowed.

  • admin - everything is permitted.

expose-fd listeners

Enables you to do a seamless reload of HAProxy Enterprise when master-worker mode is enabled.

Access the Runtime API

You can send plain text commands to the API. An easy way to try it is by using the Linux echo command and piping the result to socat.

socat stands for "SOcket CAT" and is a versatile networking utility available on Linux. It has the ability to create and manage various types of network connections, and can be used to handle a wide range of tasks involving network data transfer, redirection, and manipulation. You can visit the man pages for more information.

When using a UNIX socket, you can also use the API interactively by using socat. For example, if you exposed a UNIX socket, use this format:

$ echo "help" | \
   sudo socat stdio unix-connect:/var/run/hapee-2.2/hapee-lb.sock

If you exposed an IP address and port, use this format:

$ echo "help" | socat stdio tcp4-connect:

You can send multiple commands at once by separating them with semi-colons:

$ echo "show info;show stat" | \
   socat stdio unix-connect:/var/run/hapee-2.2/hapee-lb.sock

You can use socat without piping a command to it. Send the prompt command to start a new session with the API. Some commands, such as show cli level, work best in an interactive session because they display information about your history with the API and outside of a session, have no history to show:

$ sudo socat stdio unix-connect:/var/run/hapee-2.2/hapee-lb.sock
  > show cli level

  > operator

  > show cli level

  > quit

Next up

HAProxy Enterprise Runtime API tutorials