大网数据广告活动
服务器运维问答

Is there any default nameserver for HaProxy resolvers?

· 52CE 我爱测

I use HaProxy to forward traffic to a backend server which has a dns name instead of network address: backend default-backend server external somedomain.com:80 The problem is that there is a situation when it can become not resol…

问题原文

原帖链接 · Kirill · CC BY-SA 4.0

I use HaProxy to forward traffic to a backend server which has a dns name instead of network address:

backend default-backend
    server external somedomain.com:80

The problem is that there is a situation when it can become not resolvable. In this case HaProxy says:

Server default-backend/external is going DOWN for maintenance (DNS NX status). 0 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue. backend default-backend has no server available!

I would like HaProxy to check for DNS resolution again and start forwarding traffic whenever target DNS name is resolvable again. The problem is that I have to declare resolvers section and at least one nameserver which can resolve such address like this:

resolvers rslvr
    nameserver dns0 8.8.8.8:53

What if I do not like to declare any resolvers? I just want HaProxy checked DNS resolution the same way it does on startup. Is it possible?

If I do not use a resolver, backend just stops working and does not check if this domain is available again. Same thing happens when I do not have any nameserver in resolvers section.

Is there any way to omit explicit nameserver declaration or maybe use some default resolver used by HaProxy on startup?

已采纳解答

原帖链接 · ashirley · CC BY-SA 4.0

haproxy version 1.9 introduced a new parameter for the resolvers section which removes the need to manually list the nameservers.

parse-resolv-conf

See their docs for more info but essentially this allows you to replace

resolvers mydns
  nameserver dns1 10.0.0.1:53
  nameserver dns2 10.0.0.2:53
  hold valid           10s

with

resolvers mydns
  parse-resolv-conf
  hold valid           10s

assuming your resolv.conf (which is read by haproxy when you don't have a resolvers section) has 10.0.0.1:53 and 10.0.0.2:53 configured.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-06-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。