8

I have 2 docker containers in the same network - web and proxy running haproxy with backend

backend web
    server web web:80 check

Also init-addr is set to last,libc,none, so it does not fail if can't resolve web on start.

If I start proxy first, haproxy reports could not resolve address 'web', disabling server.

Then I start web. It become accessible by name from proxy, responding on ping and telnet. But haproxy still treats web backend down.

I expect haproxy retry checking backend web on default interval (every 2 seconds as per documentation), and, as resilt - trying to resolve dns again on every check.

How can I configure haproxy to wait until dns will resolve backend server name and then automatically up that backend?

Alexey
  • 363

1 Answers1

3

Your current config makes HAProxy able to resolve hostnames only at startup as mentioned here. Since it can't resolve web on start, the server in question will be disabled.
In order to make HAProxy do DNS resolve after startup you need to add a resolvers section.
Example:

resolvers mydns
   nameserver dns1 10.0.0.1:53
   nameserver dns2 10.0.0.2:53

backend web
   server web web:80 check init-addr last,libc,none resolvers mydns

Then whenever web becomes resolvable you will something like this in the logs:
Server web/web ('web') is UP/READY (resolves again).

Mo3m3n
  • 131