title: Set up HAProxy load balancer in docker for a docker RabbitMQ cluster
body: <p>I've set up a 3 node RabbitMQ cluster in docker using the following,</p>
  <pre><code>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
  </code></pre>
  <p>My docker network name is <em>rabbits</em>. 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,</p>
  <pre><code>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
  </code></pre>
  <p>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 <strong>amqp://guest:guest@loadbalancer:5672</strong> URL. Please help me out.</p>