我想让Envoy终止TLS,并根据从客户端到Envoy的TLS连接中使用的SNI名称,对多个群集进行反向代理。连接是TCP(不是HTTP)。
在sni_cluster
网络过滤器中,sni_1
使用TLS连接中的SNI值作为上游群集名称。我认为这意味着我应该能够创建(例如)两个集群sni_2
和sni_cluster
,并且如果TLS连接中的SNI与这两个值之一匹配,Envoy将代理这两个集群
文档还指出,必须配置documentation并在static_resources:
listeners:
- name: tcp_front_end
address:
socket_address: { address: 0.0.0.0, port_value: 5000 }
filter_chains:
- filters:
- name: envoy.filters.network.sni_cluster
- name: envoy.tcp_proxy
config:
stat_prefix: tcp
max_connect_attempts: 3
tls_context:
common_tls_context:
tls_certificates:
- certificate_chain:
filename: "/etc/envoy/cert.pem"
private_key:
filename: "/etc/envoy/key.pem"
clusters:
- name: sni_1
connect_timeout: 0.25s
type: LOGICAL_DNS
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
hosts: [{ socket_address: { address: google.com, port_value: 443 }}]
- name: sni_2
connect_timeout: 0.25s
type: LOGICAL_DNS
dns_lookup_family: V4_ONLY
lb_policy: ROUND_ROBIN
hosts: [{ socket_address: { address: news.bbc.co.uk, port_value: 443 }}]
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9091 }
之后进行配置。
我正在使用以下配置(群集主机中有虚拟值,因此请忽略这些值):
tcp_proxy
cluster
文档还指出:
必须正确设置群集之一weighted_clusters。
我没有在tcp_proxy
过滤器部分中放置tcp_proxy
部分,因为我看不到如何定义sni_cluster
应该代理的集群,因为该文档似乎推断{
"sub": "xxxx-xxxx-xxxx-xxxx-xxxxxx",
"email_verified": false,
"preferred_username": "service-account-testclient"
}
过滤器应为我指定该内容。
如何使用TCP(而非HTTP)实现SNI反向代理?