haproxy_autconfd
Welcome to haproxy_autconfd
haproxy_autconfd
is a daemon that automatically assembles a HAProxy config and restarts HAProxy if the config changes. This container is useful if you use HAProxy as reverse proxy for dynamic container workloads. Backend containers simply need to write their config fragments into the container-mapped /usr/local/etc/haproxy.inbox
directory. haproxy_autconfd
detects this change, rebuilds the config and restarts HAProxy so that the config is applied on-the-fly.
Example
- Start the container using
docker-compose up
- Write the config fragments into the container mapped
/usr/local/etc/haproxy.inbox
:- Create the backend config:
cat > /path/to/haproxy.inbox/200-mybackend.cfg <<EOF backend mybackend mode http server mybackend backendaddress:port http-request set-header X-Forwarded-Port %[dst_port] http-request add-header X-Forwarded-Proto https if {{ ssl_fc }} EOF
- Write the frontend config:
cat > /path/to/haproxy.inbox/100-mybackend.cfg <<EOF use_backend mybackend if {{ ssl_fc_sni_end -i domainmanagedbybackend }} EOF
- Create the backend config:
- Delete the config fragments if your backend is removed
See also
https://github.com/KizzyCode/HaproxyAutoconfd-rust for a shadow container that manages backend (de-)registration automatically.