haproxy pallet crate
Clojure Shell


Repository · Issues · API docs · Annotated source · Release Notes

A pallet crate to install and configure haproxy.

Dependency Information

:dependencies [[com.palletops/haproxy-crate "0.8.0-alpha.3"]]


PalletCrate VersionRepoGroupId
0.8.0-RC.4 0.8.0-alpha.3 clojars com.palletops Release Notes Source


The haproxy crate provides a server-spec function that returns a server-spec. This server spec will install and run the haproxy server. You pass a map of options to configure haproxy, as specified in settings.

The server-spec provides an easy way of using the crate functions, and you can use the following crate functions directly if you need to.

The settings function provides a plan function that should be called in the :settings phase. The function puts the configuration options into the pallet session, where they can be found by the other crate functions, or by other crates wanting to interact with haproxy.

The :proxy-group keyword can be used to provide a logical name the haproxy instance, and defaults to pallet group name.

The haproxy configuration file is based on the :config key in the settings map, and has four sub-keys, The :listen sub-key is used to specific a map of applications to proxy, where the key is a keyword naming the application, and the values are a map of configuration options for the listen clause for that application.

For example, this would configure a :my-app application, listening on port 80.

{:proxy-group :myproxy
 :config {:listen {:myapp {:server-address ""}}}}

The :frontend and :backend keys can also be used to define an application, e.g.

{:proxy-group :myproxy
 :config {:frontend {:myapp {:server-address ""}}
          :backend {:myapp {}}}}

The proxied-by function should be called in the settings phase of services that want to be proxied behind haproxy. The :proxy-group setting, which defaults to the group-name for the current target, should match the proxy-group-name argument passed to proxied-by.

For example, this would add the current target as a server for the :my-app application, contactable on the 8080 port.

(haproxy/proxied-by :proxy-group :myapp {:server-port 8080})

When the :listen key is used to set up the application, this will result in server entries under in the listen configuration section. When a :backend key is used to set up the application, this will result in server entries under the backend configuration section.

The install function is responsible for actually installing haproxy.

Live test on vmfest

For example, to run the live test on VMFest, using Ubuntu 13:

lein with-profile +vmfest pallet up --selectors ubuntu-13
lein with-profile +vmfest pallet down --selectors ubuntu-13


Copyright (C) 2012, 2013 Hugo Duncan

Distributed under the Eclipse Public License.