Ldap – Haproxy ldap session persistance

haproxyldapload balancing

Is it possible to implement session stickiness in haproxy when using it to load balance to ldap servers?

Example: I have an lb that load balances to two backend ldap servers. This works fine for reads, but if you browse the tree using directory studio, or implement pam, it causes error in pam and it flaps backs and for authenticating in directory studio.

What I'd like is for the lb to bind a user to one backend serve when they hit the ip for hte load balancer.

Best Answer

I'd suggest using stick tables in HAProxy for this.

A good reference is available on https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#stick on

Effectively you'd do something like this:

backend ldap
mode tcp
balance roundrobin
stick-table type ip size 200k expire 30m
stick on src
server s1 192.168.1.1:389
server s2 192.168.1.2:389