首页 > 解决方案 > 使用 HAProxy 的 Docker 覆盖

问题描述

我有一个 QA 环境,在其中我在同一个覆盖网络上运行我的所有应用程序和 HAProxy。我希望 HAProxy 能够在服务器不必启动的情况下启动,因此我的服务器配置例如:

backend cirrus
    option      httpclose
    option      forwardfor
    balance     leastconn

    server cirrus01 cirrus-bos01:6021 check init-addr none

注意init-addr none它允许我禁用初始 dns 解析。这种配置的问题是所有服务器都被标记为不健康并且它们永远不会变得健康,所以我总是得到 NOSRV:

2018-12-05T16:50:42+00:00localhost haproxy[12]: 192.168.10.118:64813 
[05/Dec/2018:16:50:42.981] main cirrus/<NOSRV>
0/-1/-1/-1/0 503 212 - - SC-- 1/1/0/0/0 0/0
{cirrus.docker-app.qa01.company.com|} "GET / HTTP/1.1"

即使 urlcirrus-bos01可以从容器本身获得。

现在,如果我check init-addr none要从服务器定义中删除 , haproxy 会因我尚未部署的服务而崩溃:

[ALERT] 338/165450 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:347] : 'server renderer' : could not resolve address 'ytuploader'.
[ALERT] 338/165450 (1) : Failed to initialize server(s) addr.

因为还没有真正命名的服务器ytuploader

是否有 docker/haproxy 解决方案?

标签: dockerhaproxy

解决方案


我找到了解决方案!我将服务器定义从

server cirrus01 cirrus-bos01:6021 check init-addr none

至:

server cirrus01 cirrus-bos01:6021 check init-addr last,libc,none

推荐阅读