Hmm, I don't know why, but now the ldapsearch query works.
This is the working haproxy.conf file:
Code:
global
defaults
frontend ldap
bind :389
mode tcp
description LDAP Service
option tcplog
option logasap
option socket-stats
option tcpka
timeout client 5s
default_backend ldapcluster
backend ldapcluster
server rm1 192.168.0.109:389 check
server rm2 192.168.0.111:389 check
mode tcp
balance roundrobin
option tcpka
timeout server 2s
timeout connect 1s
I created a failover cluster now for HAProxy using Keepalived and even against the virtual IP both the ldapsearch query and LDAP authentication of a web application work perfectly.
This is the keepalived.conf file for HAProxy1 ( = ha1 = 192.168.0.92 ):
Code:
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface ens160 # interface to monitor
state MASTER # MASTER on ha1, BACKUP on ha2
virtual_router_id 51
priority 101 # 101 on ha1, 100 on ha2
virtual_ipaddress {
192.168.0.112 # virtual ip address
}
track_script {
chk_haproxy
}
}
This is the keepalived.conf file for HAProxy2 ( = ha2 = 192.168.0.103 ):
Code:
vrrp_script chk_haproxy {
script "killall -0 haproxy" # check the haproxy process
interval 2 # every 2 seconds
weight 2 # add 2 points if OK
}
vrrp_instance VI_1 {
interface ens160 # interface to monitor
state BACKUP # MASTER on ha1, BACKUP on ha2
virtual_router_id 51
priority 101 # 101 on ha1, 100 on ha2
virtual_ipaddress {
192.168.0.112 # virtual ip address
}
track_script {
chk_haproxy
}
}
Thank you @tyler2016 for your considerations and your patience!