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

  5. Configure Apache 2 to pass request to the Unix socket through the API created by the REST API.

    Copy the following code under /etc/apache2/conf-available/hapee.conf:

    <IfModule mod_proxy_fcgi.c>
       ProxyPassMatch ^/(api(/.*)?)$ unix:/var/run/hapee-1.6/hapee-rest-api.sock|fcgi://localhost/

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