Search code examples
haproxy

Haproxy multi-line config


Is it possible to split configuration arguments (in haproxy.cfg) onto multiple lines?

Example

Current

frontend
     https-in bind :443 ssl strict-sni crt </path/to/cert1.pem> crt </path/to/cert2.pem> crt </path/to/cert3.pem> ...

Ideal

frontend 
    https-in bind :443 ssl strict-sni
        crt </path/to/cert1.pem>
        crt </path/to/cert2.pem>
        crt </path/to/cert3.pem>
        ...

Error when trying ideal

$ /usr/sbin/haproxy -c -V -f /etc/haproxy/haproxy.cfg
[ALERT] 343/210133 (25646) : parsing [/etc/haproxy/haproxy.cfg:45] : unknown keyword 'crt' in 'frontend' section
[ALERT] 343/210133 (25646) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 343/210133 (25646) : Fatal errors found in configuration.

Solution

  • You can't do multiline syntax in the haproxy.cfg.

    Take a look at the file format documentation: https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#2.1

    Update:

    Thanks to the comment from Venky I see that there is also the option to use crt-list which does provide an option for multi line pem file references. https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#5.1-crt-list




    the improved config will be:

    frontend 
        https-in bind :443 ssl strict-sni
        crt-list </path/to/list.txt>
            ...
    

    the list.txt:

    </path/to/cert1.pem>
    </path/to/cert2.pem>
    </path/to/cert3.pem>