小编Nai*_*aba的帖子

HAProxy 配置文件中的主机名

我的 haproxy.cfg 文件有两个使用主机名的后端服务器:

server ops-ca-revealv2e-prod-1 ops-ca-revealv2e-prod-1:443 cookie ops-ca-revealv2e-prod-1 ssl weight 1 maxconn 512 check

server ops-ca-revealv2e-prod-2 ops-ca-revealv2e-prod-2:443 cookie ops-ca-revealv2e-prod-2 ssl weight 1 maxconn 512 check
Run Code Online (Sandbox Code Playgroud)

这些主机名是 Amazon OpsWorks 的一部分,并且会在实例启动或关闭时自动注入 /etc/hosts。如果我在其中一个实例关闭时尝试重新启动 HAProxy,则会收到错误消息:

[ALERT] 362/225440 (27202) : parsing [/opt/haproxy-ssl/haproxy.cfg:42] : 'server ops-ca-revealv2e-prod-2' : invalid address: 'ops-ca-revealv2e-prod-2' in 'ops-ca-revealv2e-prod-2:443'
[ALERT] 362/225440 (27202) : Error(s) found in configuration file : /opt/haproxy-ssl/haproxy.cfg
[ALERT] 362/225440 (27202) : Fatal errors found in configuration.
Run Code Online (Sandbox Code Playgroud)

有没有办法告诉 HAProxy 检查主机名是否有效?如果有效,则使用它,如果无效,则忽略它。

load-balancing hosts hostname haproxy

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

haproxy ×1

hostname ×1

hosts ×1

load-balancing ×1