0

I've set up a 3 node RabbitMQ cluster in docker using the following,

docker run -d --rm --net rabbits `
-v ${PWD}/config/rabbit-1/:/config/ `
-e RABBITMQ_CONFIG_FILE=/config/rabbitmq `
-e RABBITMQ_ERLANG_COOKIE=WIWVHCDTCIUAWANLMQAW `
--hostname rabbit-1 `
--name rabbit-1 `
-p 8081:15672 `
-p 8084:5672 `
rabbitmq:3.8-management

My docker network name is rabbits. I'm struggling to setup a docker HAProxy load balancer for this cluster. I'm a complete novice in both docker and load balancing, so the config file doesn't make much sense to me. The following is my current haproxy.config,

global
        debug
 
defaults
        log     global
        mode    tcp
        timeout connect 5000
        timeout client 50000
        timeout server 50000

frontend main
        bind *:8089
        default_backend app

backend app
        balance roundrobin
        mode http
        server          rabbit-1 172.18.0.2:8084
        server          rabbit-2 172.18.0.3:8085
        server          rabbit-3 172.18.0.4:8086

The 172.18.0.* is my RabbitMQ nodes IP address, I'm not sure if I'm supposed to give the ip address or the network name in the backend app. And I'm not sure about the mode as well. What I'm trying to achieve is have my client 3 node microservice application send/receive messages through amqp://guest:guest@loadbalancer:5672 URL. Please help me out.

2
  • Use mode tcp. You'll need to adjust port in your amqp:// URL.
    – AlexD
    Jan 26, 2022 at 7:17
  • I'll try updating the mode as tcp. My other doubt is that the docker container ip address. My backend app ip address 172.18.0.2 is from the docker container and I'm not sure if i'm supposed to do the way I've done right now. Jan 26, 2022 at 8:05

0

You must log in to answer this question.

Browse other questions tagged .