0

I'm on Ubuntu 16.04; I set up HAProxy as an entrypoint to services defined by domain names; those domain names are served by a DNS server (coredns) in the same machine (or VLAN network). Using nslookup or dig utilities, we obtain the name resolution; but HAProxy throws the error:

[ALERT] 134/160502 (25218) : parsing [/etc/haproxy/haproxy.cfg:57] : 'server example' : could not resolve address 'example.service.com'.
[ALERT] 134/160502 (25218) : Failed to initialize server(s) addr.

In my /etc/haproxy/haproxy.cfg file, I have a resolvers section as below :

resolvers dnsmasq
  nameserver ip 10.80.10.25:5353

resolvers coredns
  nameserver ip 10.80.10.25:53

and I set up a frontend and a backend which refers to a domain name resolved by both servers added above as resolvers :

frontend example-service
    bind :80
    mode http
    default_backend example

backend example
    mode http
    balance roundrobin
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    option httpchk HEAD / HTTP/1.1rnHost:localhost
    server example example.service.com resolvers coredns check inter 1000

With dig we have:

dig @10.80.10.25 -p 53 example.service.com +noall +answer

; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> @10.80.10.25 -p 53 example.service.com +noall +answer
; (1 server found)
;; global options: +cmd
example.service.com.    3600    IN  A   127.0.0.1
  • My backend works now after moving the /etc/resolv.conf file which was preventing the translation of the service name. However, I don't understand why the HAProxy resolvers don't bypass the esolv.conf, and how this file continues to provide the names translation exclusively ? – Agdmoun khalid May 16 '19 at 11:35
  • maybe dnsmasq does not bypass resolv.conf – Martynas Saint May 16 '19 at 12:16

0 Answers0