I can’t seem to connect to RabbitMQ cluster behind this HAProxy configuration:
The RabbitMQ web interface shows up fine on the HAProxy published port 15672 but there is no connectivity from client containers trying to connect to HAProxy on port 5672.
global
log stdout format raw local0
defaults
mode tcp
log global
timeout connect 10s
timeout client 1m
timeout server 1m
resolvers docker
nameserver dns1 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold other 10s
hold refused 10s
hold nx 10s
hold timeout 10s
hold valid 10s
hold obsolete 10s
frontend stats
mode http
bind *:8404
stats enable
stats uri /
stats refresh 10s
frontend rabbitmq_frontend
bind *:5672 accept-proxy
default_backend rabbitmq_backend
backend rabbitmq_backend
mode tcp
option tcplog
balance roundrobin
option tcp-check
tcp-check connect port 5672
server rabbitmq1 rabbitmq-1:5672 check resolvers docker
server rabbitmq2 rabbitmq-2:5672 check resolvers docker
server rabbitmq3 rabbitmq-3:5672 check resolvers docker
# Add more servers if needed
frontend rabbitmq_management
bind *:15672 # Replace with your desired port or IP if necessary
mode http
default_backend rabbitmq_management_servers
backend rabbitmq_management_servers
mode http
balance roundrobin # You can change the load balancing algorithm if needed
option httpchk GET / # Check health by making an HTTP GET request to the root
http-check expect status 200
server rabbitmq-mgt rabbitmq-1:15672 check resolvers docker
server rabbitmq-mgt2 rabbitmq-2:15672 check resolvers docker
server rabbitmq-mgt3 rabbitmq-3:15672 check resolvers docker
This is example from one HAProxy container showing connections to RabbitMQ web interface:
docker exec -it 3bee066ea790 netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8404 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.11:43543 0.0.0.0:* LISTEN
tcp 0 0 192.168.6.92:52690 192.168.6.254:15672 ESTABLISHED
tcp 0 0 192.168.1.223:15672 192.168.1.4:50951 ESTABLISHED
tcp 0 0 192.168.6.92:53316 192.168.6.3:15672 ESTABLISHED
tcp 0 0 192.168.6.92:58052 192.168.6.253:15672 ESTABLISHED
udp 0 0 127.0.0.1:43245 127.0.0.11:53 ESTABLISHED
udp 0 0 127.0.0.11:60884 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 3 [ ] STREAM CONNECTED 464812
unix 3 [ ] STREAM CONNECTED 464813
This is telnet connection from a client container to another HAProxy container on port 5672 (there is only connection to HAProxy, but no connection to RabbitMQ servers from there on):
docker exec -it e2bfc4dd6e98 netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:15672 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5672 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.11:38041 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8404 0.0.0.0:* LISTEN
tcp 0 0 192.168.6.93:5672 192.168.6.222:65473 ESTABLISHED
udp 0 0 127.0.0.1:58900 127.0.0.11:53 ESTABLISHED
udp 0 0 127.0.0.11:56395 0.0.0.0:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node Path
unix 3 [ ] STREAM CONNECTED 470962
unix 3 [ ] STREAM CONNECTED 470961
1 post - 1 participant