Is it possible to put haproxy between Consul servers and clients?

I have a RabbitMQ cluster with a Consul 3-node cluster as the service discovery backend. This is working great.

However, RabbitMQ’s consul plugin only lets you specify one endpoint (ie, node1 in my Consul 3-node cluster). So if that endpoint goes down, RabbitMQ isn’t able to failover to any other endpoints. (There’s a rabbitmq-server GitHub issue open for this limitation, but it hasn’t had any traction.)

I thought a possible workaround could be to put Haproxy in between RabbitMQ and Consul (round-robin, tcp mode), but RabbitMQ complains about a 404 (Consul responded to a health check with a 404 status, will wait and try re-registering). I’m not sure if that’s because of user error or because it’s just not possible to do this with Consul. Is this proxying approach possible?

Thank you!

So turns out I misunderstood how Consul is meant to be used. Instead of having downstream applications connecting directly to a centralized Consul cluster, you’re meant to have Consul running on all servers/instances in client mode. You configure your downstream application to connect to the local Consul, which in turn connects to your Consul servers.

Funnily enough, Consul in client mode is sort of doing what I was unsuccessfully trying to get Haproxy to do (ie, forward requests to my Consul servers and continue working if any one of the servers is down).

The hoops I’ve had to jump through to get things working in Docker Swarm is another story, but my questions in this post no longer need answering :slight_smile:

1 Like