Dockerfile for haproxy
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test-website
.gitignore
Dockerfile
Dockerfile-1.6
README.md
etc-haproxy-haproxy.cfg.template
etc-haproxy-haproxy.cfg.template2
etc-haproxy-haproxy.cfg.template3
etc-rsyslog.conf
etc-rsyslog.d-49-haproxy.conf
etc-rsyslog.d-50-default.conf
etc-supervisor-conf.d-supervisord.conf
etc-supervisord.conf
gencert.sh

README.md

HA proxy for HTTP traffic

  1. Configure the backends in haproxy.cfg (copy the template). The rows looks like this: server SERVER_NAME IP:PORT check. SERVER_NAME is only used for logging purposes.

  2. The stats logins also needs to be updated in haproxy.cfg, see stats auth admin:password.

  3. Build: docker build --rm -t haproxy .

  4. Run:

    docker run -t -i -p 80:80 -p 443:443 -p 1883:1883 -p 8883:8883 --restart="on-failure:10"
    --link beservices:beservices --name=haproxy -h haproxy
    haproxy /bin/bash -c "supervisord; bash"

When using docker swarm:

docker run -ti -p 80:80 -p 443:443 -p 1883:1883 -p 8883:8883 --restart="on-failure:10" \
--net=net0 --name=haproxy -h haproxy \
haproxy /bin/bash -c "supervisord; bash"

Disconnect from the shell with ctrl-p ctrl-q (you can connect later with docker attach haprox)

  1. Check the logs: docker logs lb

  2. Check the stats at http://[IP]/haproxy?stats

The amount of logging is controlled by: log 127.0.0.1 local0 debug in haproxy.cfg

Update configuration

It is possible to update the configuration of haproxy while the container is running.

  1. Connect to the container with: docker attach haproxy
  2. Edit config file: nano /etc/haproxy/haproxy.cfg
  3. Restart haproxy: supervisorctl restart haproxy