Installing the REST / JSON Web API
The HAProxy Enterprise API is a RESTful API that allows you to modify the HAProxy Enterprise configuration without editing configuration files manually or granting shell access on the load balancers.
This API is deprecated in newer versions (>= 1.9) in favor of the Data Plane API.
Install the REST API
If you have HAProxy Enterprise 1.6r2 installed, this installation will remove it. So check that the VRRP priority is reduced, and that the required modules are ready to have their 1.8r1 versions installed.
Check that you have the following installed:
hapee-1.8r1-cli(the command line API)
hapee-1.8r1-cli-lb(scripts to automate socket operations on the running HAProxy instance)
Install the Apache2 Web server by running apt-get install apache2. If you do not want to use Apache 2, you can use another Web server that supports FastCGI.
Start the REST API service:
service hapee-1.8-rest-api start
Be mindful of security considerations. Only authorized users should access the API. Some options at your disposal are: IP address restrictions, password authentication, TLS client certificate authentication, and any or all combinations of these.
Configure Apache 2 to pass request to the Unix socket through the API created by the REST API.
Copy the following code under
<IfModule mod_proxy_fcgi.c> ProxyPassMatch ^/(api(/.*)?)$ unix:/var/run/hapee-1.8/hapee-rest-api.sock|fcgi://localhost/ </IfModule>
Run the following commands:
a2enmod proxy_fcgi // this enables the fcgi module
a2enconf hapee // this enables the configuration bit we just added to apache2
service apache2 reload // to reload apache2 service
Test the API to ensure that it functions:
$ wget -O - 192.168.122.185/api/2/scope/root/l7/farm
--2016-11-18 17:27:27-- http://192.168.122.185/api/2/scope/root/l7/farm Connecting to 192.168.122.185:80... connected. HTTP request sent, awaiting response... 200 OK Length: unspecified [application/json] Saving to: STDOUT  2016-11-18 17:27:27 (210 KB/s) - written to stdout 
The [ ] in the response indicates that there are no farms configured yet. However, as long as the response returns JSON data, the basic API is getting requests and functioning normally.