Installing the REST / JSON Web API

The HAPEE API is a RESTful API that allows you to modify the HAPEE configuration without editing configuration files manually or granting shell access on the load balancers.

Install the REST API

1. Install the hapee-1.6r2-rest-api package.

If you have HAPEE 1.6r2 installed, this will remove it. So check that the VRRP priority is reduced, and that the required modules are ready to have their 1.6r2 versions installed.

2. Check that you have the following installed:

  • hapee-1.6r2-cli (the command line API)
  • hapee-1.6r2-cli-lb (scripts to automate socket operations on the running HAProxy instance)

3. 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.

4. Start the REST API service:

# service hapee-1.6-rest-api start
Be mindful of the security considerations. Only authorized users need access to the API. Some options at your disposal are: IP address restrictions, password authentication, TLS client certificate authentication, and any or all combinations of these.

7. Restart apache2:

# service apache2 restart

8. Test the API to ensure that it functions:

$ wget -O -
--2016-11-18 17:27:27--
Connecting to 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 [4]
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.