【问题标题】:Varnish for backend hosted inside kubernetes用于托管在 kubernetes 内的后端的清漆
【发布时间】:2020-10-07 15:55:53
【问题描述】:

我正在尝试在本地运行清漆缓存。使用 nginx-ingress-controller 代理 kubernetes 管理的域。

因此,我有 ELB 和入口控制器将请求路由到 3 个不同的 kubernetes 节点,我收到以下错误:

➜ docker logs a5d30511ffc756f2b5cf4b243ff66d1d9e9d7d47f560f3ca03d07b42efcc763a
Could not delete 'vcl_boot.1601710985.783551/vgc.sym': No such file or directory
Error:
Message from VCC-compiler:
Backend host "sub.domain.com:443": resolves to too many addresses.
Only one IPv4 and one IPv6 are allowed.
Please specify which exact address you want to use, we found all of these:
    31.208.6.184:443
    31.208.221.23:443
    35.161.52.197:443
('/etc/varnish/default.vcl' Line 4 Pos 11)
  .host = "sub.domain.com:443";
----------###########################-


In backend specification starting at:
('/etc/varnish/default.vcl' Line 3 Pos 1)
backend default {
#######----------

Running VCC-compiler failed, exited with 2
VCL compilation failed

所以我的配置是:

vcl 4.0;

backend default {
  .host = "sub.domain.com:443";
}

可以做什么?

【问题讨论】:

    标签: kubernetes varnish nginx-ingress varnish-vcl


    【解决方案1】:

    首先,您不应该在.host 属性中包含端口号。有一个单独的.port 属性。

    语法如下:

    backend default {
        .host = "xxx";
        .port = "xxx";
    }
    

    如果不指定端口属性,Varnish 将使用端口80 作为默认值。

    理论上,您可以将 .port = "443"; 添加到后端定义中,但使用端口 443 意味着 TLS 连接。

    Varnish Cache,Varnish 的开源版本,不支持使用 TLS 的后端连接。但是,Varnish Enterprise,Varnish 的商业版本。

    请参阅https://docs.varnish-software.com/varnish-cache-plus/features/backend-ssl/ 了解有关Varnish Enterprise 中的后端 TLS 的更多信息。 见http://varnish-cache.org/docs/trunk/reference/vcl.html#backend-definition

    您的具体错误

    出现您的特定错误是因为您使用的主机名解析为多个 IP 地址。

    请使用另一个主机名,该主机名仅指单个 IP,或者使用您尝试使用的节点的 IP 地址。

    另一种选择是切换到 Varnish Enterprise 并使用 dynamic backend module

    【讨论】:

    • 还是同样的问题。后端主机 XXX 解析到的地址过多。
    • 我更新了我的答案并专门解决了您的错误。
    猜你喜欢
    • 1970-01-01
    • 2016-09-21
    • 1970-01-01
    • 2021-05-09
    • 2016-02-02
    • 2017-07-21
    • 2014-10-16
    • 2020-04-09
    • 2017-11-24
    相关资源
    最近更新 更多