Hi,

On Fri, Jan 08, 2010 at 12:51:46AM +1100, Aristedes Maniatis wrote:
> I'm working on a web UI for administering the haproxy config and I have a 
> question I can't find the answer to in the documentation. Are the listener 
> blocks unique with respect to IP:port? That is, is this valid:
> 
> 
> listen
>   bind 1.2.3.4:80
>   acl someAcl...
>   server 1.2.5.1 ifsomeAcl
> 
> listen
>   bind 1.2.3.4:80
>   acl someOtherAcl...
>   server 1.2.5.1 if someOtherAcl
> 
> Are these listeners like a Unix listener, only one unique IP:port pair is 
> allowed. Or are duplicates OK and they are executed in order from the top 
> to the bottom under a backend server is matched?

This depends on the OS in fact. Haproxy accepts such a configuration, but
on most OSes it will not be able to bind the port for the second instance
because the OS will refuse to bind it a second time. Some variants or patched
ones will accept it though. In practice, the example above is really useless
because you can't know what listener will get the request, the OS will randomly
distribute it to any socket.

However, it is very useful when you bind to an interface :

 listen
   bind 1.2.3.4:80 interface eth0
   acl someAcl...
   server 1.2.5.1 ifsomeAcl
 
 listen
   bind 1.2.3.4:80 interface eth1
   acl someOtherAcl...
   server 1.2.5.1 if someOtherAcl

This time there is no ambiguity and the OS will allow it (assuming it
supports per-interface binding).

Regards,
Willy


Reply via email to