HAProxy Enterprise Documentation 1.6r2

Resolvers

A resolvers section lists DNS nameservers that HAProxy Enterprise will query when it needs to resolve a hostname to an IP address. Each resolvers keyword is followed by a label, such as mynameservers, to differentiate it from others.

resolvers mynameservers
   nameserver ns1 192.168.2.10:53
   nameserver ns2 192.168.3.10:53

Each nameserver line indicates the IP address and port of a DNS nameserver. HAProxy Enterprise sends a query to all of the nameservers and uses the first, valid response that it receives.

Resolvers configuration examples

The most common way to use this feature is to configure backend server hostnames instead of IP addresses. When defining a list of servers in a backend or listen section, you can use DNS names.

In the following configuration sample, the servers defined in backend webservers are using the resolvers field on each server line to reference the resolvers section that will be used to resolve the server's name.

resolvers mynameservers
   nameserver ns1 192.168.2.10:53
   nameserver ns2 192.168.3.10:53

backend webservers
   server s1 hostname1.example.com:80 check resolvers mynameservers
   server s2 hostname2.example.com:8080 check resolvers mynameservers
   server s3 hostname3.example.com:8080 check resolvers mynameservers

Adjusting DNS settings

You can adjust how HAProxy Enterprise queries nameservers and caches the responses. The following sample configuration contains a resolvers section with all available options configured.

resolvers mynameservers
   nameserver ns1 192.168.2.10:53
   nameserver ns2 192.168.3.10:53





   # How long to "hold" a backend server's up/down status depending on the name resolution status.
   # For example, if an NXDOMAIN response is returned, keep the backend server in its current state (up) for
   # at least another 30 seconds before marking it as down due to DNS not having a record for it.
   hold valid    10s
   hold other    30s
   hold refused  30s
   hold nx       30s
   hold timeout  30s
   hold obsolete 30s

   # How many times to retry a query
   resolve_retries 3

   # How long to wait between retries when no valid response has been received
   timeout retry 1s

See also

DNS Service Discovery


Next up

Peers