Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
/ homelab-haproxy Public archive

Automated HA-Proxy for Docker containers

License

Notifications You must be signed in to change notification settings

danie1k/homelab-haproxy

Repository files navigation

QA Build Status Docker Hub Build Status Docker Image Version MIT License

Automated HA-Proxy for Docker containers

Based on https://github.com/clearlinux/dockerfiles/tree/master/haproxy

The idea behind this container is to

  • Monitor changes in certain given Docker Network
  • React when containers connect/disconnect to this network
  • Automatically map names of these containers in HA-Proxy to FQDNs

Usage

  • Run this container at least in two Docker Networks.
  • By default, it will listen for requests on eth0, so make your end-user-facing network to be first on a list.
  • Monitoring tool will automatically modify HA-Proxy settings
  • If any new container will show up, it will be added to configuration if it has the following labels set:
    • haproxy.source_port
    • haproxy.target_port
  • HA-Proxy config blocks are generated using Jinja template engine
  • Built-in templates can be easily overridden by adding the templates directory to HAPROXY_CONFIG_VOLUME with .j2 file(s)

Environment variables

  • DOCKER_API_BASE_URL="unix:///var/run/docker.sock"
  • DOMAIN_NAME="local"
  • HAPROXY_CONFIG_VOLUME="/usr/local/etc/haproxy"
  • HAPROXY_PID_FILE="/var/run/haproxy.pid"
  • NETWORK_MONITOR_DEBOUNCE="10" - in seconds
  • NETWORK_NAME="bridge"

Volumes

  • /usr/local/etc/haproxy
  • /var/run/docker.sock