HA-Proxy 1.7.5-2 on Debian not accepting LXD container names

Having followed this great guide on lxd and haproxy, I’ve only managed to get haproxy working if I use the IP of the container and not the container name…

For example, this line in a backend section works fine
server apache_00 check

But using the container name or the container’s hostname doesn’t work. The container name returns error 503 from haproxy and the container hostname gives a page not redirecting error.

It’s not a show-stopper but I was surprised to find that Ubuntu 16.04 is using haproxy version 1.6.3, while Debian 9 uses 1.7.5-2.

So I guess I’m curious as to how @simos managed to use the container’s names in the tutorial?

Within the containers, you can use those hostnames like mycontainer.lxd because those are provided by LXD`s dnsmasq DNS server for the containers.

Try to ping those hostnames within a container to verify first that name resolution works.

I have not tested this setup with 18.04 but I cannot think why it should fail.

Yeah, I can ping container 1 from container 2 no problem… I tested this from the ha-proxy container and it pinged my other containers on the same host no problem…

Then, two things here.

  1. Check whether the semantics changed between there major versions of HAproxy.

  2. I suppose that you have restarted the HAProxy service several times. If you still get the error, then it is likely some other issue unrelated to containers.

For example, you may be trying to use the PROXY protocol and you do not terminate the connections.
If all fail, try to follow the guide as described with Ubuntu and the bit by bit to your setup.

Hi @simos , thank you for this… my workaround is fine for now, using IP addresses is fine given the relatively small number of containers I’ve got running…

I’ll return to this if I need container names in the future!