I'm building an haproxy config file that has multiple front and backends. It's going to be several hundred lines long and I'd rather split it up into separate files for each of the different websites that I want to loadbalance.
Does HAProxy offer the ability to link to partial config files from the main haproxy.cfg file?
Configuration files can't be linked together from a configuration directive.
However HAProxy can load multiple configuration files from its command line, using the -f
switch multiple times:
haproxy -f conf/http-defaults -f conf/http-listeners -f conf/tcp-defaults -f conf/tcp-listeners
If you want to be flexible with the amount of config files you can even specify a directory like this: -f /etc/haproxy
. The files will then be used in their lexical order, newer files overriding older files.
See the mailing list for an example, if provides links to the documentation. This information can be found in the management guide, not the regular docs.