haproxy - pass original / remote ip in tcp mode

Posted by Vito Botta on Server Fault See other posts from Server Fault or by Vito Botta
Published on 2012-07-08T17:52:17Z Indexed on 2012/07/08 21:18 UTC
Read the original article Hit count: 332

Filed under:
|

I've got haproxy set up with keepalived for load balancing and ip failover of a percona cluster, and since it works great I'd like to use the same lb / failover for another service/daemon.

I've configured haproxy this way:

listen my_service 0.0.0.0:4567
    mode tcp
    balance leastconn
    option tcpka
    contimeout      500000
    clitimeout      500000
    srvtimeout      500000

    server host1 xxx.xxx.xxx.xx1:4567 check port 4567 inter 5000 rise 3 fall 3
    server host2 xxx.xxx.xxx.xx2:4567 check port 4567 inter 5000 rise 3 fall 3

The load balancing works fine, but the service sees the IP of the load balancer instead of the actual IPs of the clients. In http mode it's quite easy to have haproxy pass along the remote IP, but how do I do in tcp mode? This is critical due to the nature of the service I need to load balance.

Thanks! Vito

© Server Fault or respective owner

Related posts about load-balancing

Related posts about haproxy