使用 consul-template 为 nginx.conf 提供 2000 多项服务

Using consul-template to render 2000+ services to nginx.conf

我们有一个使用 consul-template 为 2000 多个服务生成的 nginx conf 文件,运行 Consul 1.6.1。

我们正在尝试升级到 Consul 1.7.2 和 运行 解决 consul-template DDoSes Consul 节点代理的问题。

Node/client 代理 v1.6.1 工作正常,但 node/client 代理 v1.7.2 开始拒绝来自 consul-template 的连接。

有问题的模板(简化版)是:

{{- range services }}
{{- if (in .Tags "nginxqa1") }}
{{- range service .Name }}
{{ .Address }}
{{- end }}
{{- end }}
{{- end }}

在 node/client consul 上添加以下限制配置条目似乎可以解决问题:

http_max_conns_per_client = 5000

但是,这有什么影响吗?

有更好的方法吗? 我看到了这些消息:

2020/05/01 18:24:51.653257 [WARN] (runner) watching 2631 dependencies - watching this many dependencies could DDoS your consul cluster

任何想法/建议表示赞赏。

hashicorp/consul#7159 to address CVE-2020-7219中引入了http_max_conns_per_client参数。对于大多数用例,默认值 200 似乎是一个合理的默认值。但是,在像您这样的情况下,提高此值是有意义的。

提出这个的唯一缺点是任何能够与 Consul 通信的客户端 API 将能够创建最多 5000 个连接。不可能仅为特定客户端提高此限制。在将这些更改推向生产时请记住这一点。