Using HaProxy environmental variables in haproxy.cfg not working
Since you're stopping/starting with the service command, you need to specify the environment variables in your init script (e.g. /etc/init.d/haproxy
on ubuntu) not in your interactive terminal session where you're controlling the service (service haproxy start
). You can verify the environment variables available to a specific pid in the proc filesytem. If you check yours for haproxy, it'll likely be only TERM and LANG, because that's the only environment which gets passed via service to the init script (manpage for service).
# cat /proc/$(pgrep haproxy)/environ
If instead of starting daemonized haproxy from the init script you directly run haproxy you'll likely see the behavior you're looking for:
# haproxy -f /etc/haproxy/haproxy.cfg
To solve this, edit the init script /etc/init.d/haproxy
and set your variables there:
export FE_PORT_8000_TCP_ADDR=172.17.0.4