Public | Automated Build

Last pushed: 3 years ago
Short Description
Short description is empty for this repo.
Full Description


Dynamic haproxy configuration using consul packed into a Docker container that weighs 18MB.


This project combines Alpine Linux, consul template, and haproxy
to create a proxy that forwards traffic to services registered in consul.

How it works

First, you must set up a wildcard dns (using something like CloudFlare or This means that if your domain is, any request to a <name> will resolve to the IP of your haproxy container.

Inside the haproxy container, a header match is used to map <application> to the service registered in consul under aplication.


  docker build -t haproxy . 


If you don't want to configure wildcard dns, you can use In this example, we are going to assume that the IP of your server is, then all domains in will forward to your host.

Start the container as follows:

docker run --net=host --name=haproxy -d -e asteris/haproxy-consul

If you have wildcard DNS set up for your company (say at * use the following:

docker run --net=host --name=haproxy -d -e asteris/haproxy-consul  

Now that it is set up, connect to an app registered via consul.

curl -L

Or if you do not have a wildcard DNS

curl -L


If you wish to override the config and template files, mount a volume and change the CONSUL_CONFIG environment variable upon launch. In docker this is via the -e option:

docker run -v /host/config:/my_config -e CONSUL_CONFIG=/my_config -net=host --name=haproxy -d -e asteris/haproxy-consul 
Configure using the following environment variables:

  HAPROXY_DOMAIN        The domain to match against
                        (default: for

Consul-template variables:
  CONSUL_TEMPLATE       Location of consul-template bin 
                        (default /usr/local/bin/consul-template)

  CONSUL_CONNECT        The consul connection
                        (default consul.service.consul:8500)

  CONSUL_CONFIG         File/directory for consul-template config

  CONSUL_LOGLEVEL       Valid values are "debug", "info", "warn", and "err".
                        (default is "debug")


Released under an Apache 2.0 License. See LICENSE

Docker Pull Command
Source Repository