当前位置:网站首页>Pulsar的Proxy支持和SNI路由
Pulsar的Proxy支持和SNI路由
2022-07-01 02:20:00 【swadian2008】
目录
(1)为 layer-4 SNI routing 设置 ATS Proxy
(2)使用 SNI routing 配置 Pulsar-client
(2)使用 SNI routing 进行 geo-replication
代理服务器是一种中介服务器,它跨Internet将来自多个客户端的请求转发到不同的服务器。代理服务器在正向和反向代理场景中都扮演着“交通警察”的角色,并为您的系统带来了负载平衡、性能、安全性、自动扩容和缩容等好处。
Pulsar中的代理充当反向代理,并在 brokers 面前创建一个网关。Pulsar不支持 Apache Traffic Server(ATS)、HAProxy、Nginx 和 Envoy 等代理。但这些代理服务器都支持 SNI 路由(SNI routing)。SNI 路由用于将流量路由到目标,而无需终止SSL连接。第4层路由提供了更大的透明度,因为出站连接是通过检查 clent TCP 数据包中的目标地址来确定的。
Pulsar客户端(Java、C++、Python)支持SNI路由协议,因此您可以通过 proxy 连接到 brokers 。本文档将指导你如何设置 ATS 代理、启用 SNI 路由以及通过ATS代理将 Pulsar client 连接到broker 。
Pulsar 中的 ATS-SNI Routing
为了支持带有 ATS 的第4层 SNI 路由(layer-4 SNI routing),入站连接必须是TLS连接。Pulsar client 支持基于 TLS 连接的 SNI 路由协议,因此当 Pulsar client 通过 ATS 代理连接到 broker 时,Pulsar 将 ATS 用作反向代理。
Pulsar 支持 SNI 路由进行地域复制(geo-replication),因此 brokers 可以通过 ATS proxy 连接到其他集群中的 brokers。
本节介绍如何设置和使用 ATS 作为反向代理,以便 Pulsar clients 可以使用基于 TLS 连接的 SNI 路由协议通过 ATS proxy 连接到 brokers。
(1)为 layer-4 SNI routing 设置 ATS Proxy
为了支持 layer-4 SNI routing 你需要配置 records.conf and ssl_server_name.conf files.

The records.config file is located in the /usr/local/etc/trafficserver/ directory by default. 该文件列出了 ATS 使用的可配置变量。
配置 records.config files,请完成以下步骤。
- 更改 proxy 侦听的 TLS 端口(
http.server_ports),修改 proxy certs (ssl.client.cert.pathandssl.client.cert.filename) 确保 TLS 通畅(TLS tunneling)。 - 配置 tunneling to the broker 的服务端口,如果 Pulsar brokers 正在监听
4443和6651 端口,在http.connect_ports 配置中添加brokers 服务端口。
下面是一个示例。
# PROXY TLS PORT
CONFIG proxy.config.http.server_ports STRING 4443:ssl 4080
# PROXY CERTS FILE PATH
CONFIG proxy.config.ssl.client.cert.path STRING /proxy-cert.pem
# PROXY KEY FILE PATH
CONFIG proxy.config.ssl.client.cert.filename STRING /proxy-key.pem
# The range of origin server ports that can be used for tunneling via CONNECT. # Traffic Server allows tunnels only to the specified ports. Supports both wildcards (*) and ranges (e.g. 0-1023).
CONFIG proxy.config.http.connect_ports STRING 4443 6651ssl_server_name 文件用来配置处理入站和出站的 TLS 连接,配置(configuration)由入站连接提供的 SNI 值确定。该文件由一些列配置项组成,每个配置项由 SNI 值(fqdn)标识。建立入站TLS连接时,TLS 协商中的 SNI 值将与此文件中指定的项进行匹配。如果值匹配,则该项中指定的值将覆盖默认值。
下面的示例显示了来自 client 的入站 SNI 主机名的映射,以及应该重定向请求的实际 broker 服务URL。比如,如果 client 端发送 SNI header pulsar-broker1,则 proxy 将请求重定向到 pulsar-broker1:6651 service URL 来创建 TLS 隧道(tunnel )。
server_config = {
{
fqdn = 'pulsar-broker-vip',
# Forward to Pulsar broker which is listening on 6651
tunnel_route = 'pulsar-broker-vip:6651'
},
{
fqdn = 'pulsar-broker1',
# Forward to Pulsar broker-1 which is listening on 6651
tunnel_route = 'pulsar-broker1:6651'
},
{
fqdn = 'pulsar-broker2',
# Forward to Pulsar broker-2 which is listening on 6651
tunnel_route = 'pulsar-broker2:6651'
},
}
在你配置 ssl_server_name.config and records.config 文件后,ATS-proxy 服务器处理 SNI 路由并在 client 端和 broker 之间创建 TCP 隧道(TCP tunnel)。
(2)使用 SNI routing 配置 Pulsar-client
ATS SNI-routing 仅适用于TLS。你首先需要为 ATS proxy 和 brokers 启用 TLS,配置 SNI 路由协议,然后通过 ATS proxy 将 Pulsar clients 连接到 brokers 。Pulsar clients 支持 SNI 路由,可以通过连接 proxy 并将目标 broker URL发送到 SNI header。此过程由内部处理。当你使用 SNI routing protocol 创建 Pulsar client 时,你仅仅只需要初始化以下配置。
String brokerServiceUrl = “pulsar+ssl://pulsar-broker-vip:6651/”;
String proxyUrl = “pulsar+ssl://ats-proxy:443”;
ClientBuilder clientBuilder = PulsarClient.builder()
.serviceUrl(brokerServiceUrl)
.tlsTrustCertsFilePath(TLS_TRUST_CERT_FILE_PATH)
.enableTls(true) // 开启TLS
.allowTlsInsecureConnection(false)
.proxyServiceUrl(proxyUrl, ProxyProtocol.SNI) // 代理配置
.operationTimeout(1000, TimeUnit.MILLISECONDS);
Map<String, String> authParams = new HashMap();
authParams.put("tlsCertFile", TLS_CLIENT_CERT_FILE_PATH);
authParams.put("tlsKeyFile", TLS_CLIENT_KEY_FILE_PATH);
clientBuilder.authentication(AuthenticationTls.class.getName(), authParams);
PulsarClient pulsarClient = clientBuilder.build();
(2)使用 SNI routing 进行 geo-replication
你可以使用 ATS proxy 进行 geo-replication 。Pulsar brokers 可以通过使用 SNI 路由连接到 geo-replication 中的 brokers。为确保 broker 的 SNI 路由能够跨集群连接,你需要将 SNI proxy URL 配置为集群元数据(cluster metadata)。如果在集群元数据中配置了 SNI proxy URL,则可以通过 SNI 路由上的 proxy 跨集群连接到 broker 。

在这个例子中,一个 Pulsar 集群被部署到两个独立的区域 us-west 和 us-east,两个区域都配置了ATS proxy,每个区域的 brokers 都支持 ATS proxy。我们在两个集群中都配置了集群元数据,所以在任何一个集群中的 brokers 都能使用 SNI routing 并且通过 ATS proxy 连接到另一个集群的 brokers。
(a) Configure the cluster metadata for us-east with us-east broker service URL and us-east ATS proxy URL with SNI proxy-protocol. // 配置集群元数据
./pulsar-admin clusters update \
--broker-url-secure pulsar+ssl://east-broker-vip:6651 \
--url http://east-broker-vip:8080 \
--proxy-protocol SNI \
--proxy-url pulsar+ssl://east-ats-proxy:443
(b) Configure the cluster metadata for us-west with us-west broker service URL and us-west ATS proxy URL with SNI proxy-protocol.
./pulsar-admin clusters update \
--broker-url-secure pulsar+ssl://west-broker-vip:6651 \
--url http://west-broker-vip:8080 \
--proxy-protocol SNI \
--proxy-url pulsar+ssl://west-ats-proxy:443
边栏推荐
- 522. Longest special sequence II
- 如何在智汀中实现智能锁与灯、智能窗帘电机场景联动?
- Electron pit Addon
- VirtualBox 安装增强功能
- Template: globally balanced binary tree
- Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation
- Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]
- 计算特殊奖金
- Fast understanding of forward proxy and reverse proxy
- Ernie gram, an explicit and complete n-gram mask language model, implements explicit n-gram semantic unit knowledge modeling.
猜你喜欢

Fix names in the table (first character uppercase, other lowercase)

CorelDRAW 2022 Chinese Simplified 64 bit direct download

Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation

Short message sending solution in medical his industry

RocketQA:通过跨批次负采样(cross-batch negatives)、去噪的强负例采样(denoised hard negative sampling)与数据增强(data augment

(翻译)使用眉状文本提高标题点击率

Fast understanding of forward proxy and reverse proxy

(translation) use eyebrow shaped text to improve Title click through rate

VirtualBox installation enhancements

How to realize the scene linkage of intelligent lock, lamp and intelligent curtain motor in zhiting?
随机推荐
SWT / anr issues - ams/wms
What are the applications of SMS in enterprises?
Leetcode interview question 17.10 Main elements
What are the top ten securities companies? In addition, is it safe to open an account online now?
How to select securities companies? In addition, is it safe to open a mobile account?
对象与对象变量
Short video platform development, relying on drawerlayout to achieve side sliding menu effect
C#生成putty格式的ppk文件(支持passphrase)
In the fourth week of June, the list - flying melon data up main growth ranking list (BiliBili platform) was released!
@ConfigurationProperties和@Value的区别
[2022] Jiangxi postgraduate mathematical modeling scheme and code
Check the disk usage of MySQL database
The latest wechat iPad protocol code obtains official account authorization, etc
Comment réaliser la liaison entre la serrure intelligente et la lampe, la scène du moteur de rideau intelligent dans le timing intelligent?
What is PMP?
CentOS installs multiple versions of PHP and switches
Open source basic software companies, looking for you to create the future together (api7.ai)
(summary I) Halcon Foundation's target finding features + becoming a regular
How to add a condition for an associated table in an SQL statement [null value required or not required]
VirtualBox 安装增强功能