5

I keep seeing HAProxy configuration examples with a two-argument syntax. Indeed, the default configuration file supplied with 1.4.18 contains this:

listen  appli1-rewrite 0.0.0.0:10001
    cookie  SERVERID rewrite
    balance roundrobin
    server  app1_1 192.168.34.23:8080 cookie app1inst1 check inter 2000 rise 2 fall 5
    server  app1_2 192.168.34.32:8080 cookie app1inst2 check inter 2000 rise 2 fall 5
    server  app1_3 192.168.34.27:8080 cookie app1inst3 check inter 2000 rise 2 fall 5
    server  app1_4 192.168.34.42:8080 cookie app1inst4 check inter 2000 rise 2 fall 5

I am noticing a complete lack of any bind option, so am I to believe that this is a shorthand for bind?

The HAProxy documentation (http://haproxy.1wt.eu/download/1.5/doc/configuration.txt) contains one unrelated example with this syntax, but does not specify, document or explain it anywhere.

The documentation simply shows listen <name>:

All proxy names must be formed from upper and lower case letters, digits,
'-' (dash), '_' (underscore) , '.' (dot) and ':' (colon). ACL names are
case-sensitive, which means that "www" and "WWW" are two different proxies.

(i.e. no spaces, so this clearly isn't just part of the name)

Is there any official documentation for this syntax?

Thanks.

  • This is confusing the hell out of me too. It seems almost completely undocumented syntax, so why is it so commonly used?! – Adam Spiers Apr 4 '17 at 22:06
3

I think I just cracked this by finding this answer on superuser.com. In HAProxy 1.3.x, the deprecated reference manual said:

2) Declaration of a listening service
=====================================

Service sections start with the 'listen' keyword :

    listen <instance_name> [ <IP_address>:<port_range>[,...] ]

By 1.4, this manual no longer existed, but it seems that this syntax continued to be accepted for backwards compatibility. In 1.6, a listen section without a bind directive started to generate warnings.

So the answer is that it's old syntax which shouldn't be used any more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.