Hi
Due to complexity of my haproxy.cfg
file, I would like to use one of more directories, from which haproxy will read all *.cfg
files.
In my /etc/haproxy/haproxy.cfg
, I would like to add a variable with the path (or multiple paths) of the config directory (e.g. /etc/haproxy/haproxy.d
) - like many other servers do (e.g. Apache, NGINX, named, etc.)
I wasn’t able to find such a setting.
How can this be done?
P.S. I managed to find a solution, which works, but is too static and clunky - create a directory by hand, and modify haproxy’s systemd unit file to include that directory. I’m looking for a more dynamic, elegant solution.
$ cat /etc/systemd/system/multi-user.target.wants/haproxy.service | egrep -v '^#|^ *$'
[Unit]
Description=HAProxy Load Balancer
Documentation=man:haproxy(1)
After=syslog.target network.target
[Service]
EnvironmentFile=-/etc/sysconfig/haproxy
Environment="CONFIG=/etc/haproxy/haproxy.cfg -f /etc/haproxy/haproxy.d" "PIDFILE=/run/haproxy.pid" "EXTRAOPTS=-S /run/haproxy-master.sock"
ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS
ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS
ExecReload=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS
ExecReload=/bin/kill -USR2 $MAINPID
KillMode=mixed
Restart=always
SuccessExitStatus=143
Type=notify
[Install]
WantedBy=multi-user.target