当前位置:网站首页>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
边栏推荐
- Rocketqa: cross batch negatives, de noised hard negative sampling and data augmentation
- CorelDRAW 2022 Chinese Simplified 64 bit direct download
- How does ZABBIX configure alarm SMS? (alert SMS notification setting process)
- 开源基础软件公司,寻找一起创造未来的你(API7.ai)
- LabVIEW calculates the camera image sensor resolution and lens focal length
- [fundamentals of wireless communication-15]: illustrated mobile communication technology and application development-3-overview of digital communication 2G GSM, CDMA, 3G wdcma/cdma200/td-scdma, 4G LTE
- 先写API文档还是先写代码?
- How does the property send a text message to the owner?
- PMP是什麼?
- 对象与对象变量
猜你喜欢

Ernie-gram, 显式、完备的 n-gram 掩码语言模型,实现了显式的 n-gram 语义单元知识建模。

FL studio20.9 fruit software advanced Chinese edition electronic music arrangement

Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"
![SQL语句关联表 如何添加关联表的条件 [需要null值或不需要null值]](/img/91/0efbc13597be4dba5b9cf4e8644e35.png)
SQL语句关联表 如何添加关联表的条件 [需要null值或不需要null值]

Machine learning 9-universal approximator radial basis function neural network, examining PDA and SVM from a new perspective

The mobile edge browser cannot open the third-party application

Batch import of Excel data in applet

VirtualBox 安装增强功能

nacos配置中心使用教程
![Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]](/img/6e/279dbb7a8d7a5ecd240de464c5b8b2.png)
Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]
随机推荐
CorelDRAW 2022 Chinese Simplified 64 bit direct download
SWT/ANR问题--StorageManagerService卡住
【2022年】江西省研究生数学建模方案、代码
SWT/ANR问题--Native方法执行时间过长导致SWT
What are the preferential activities for stock account opening? In addition, is it safe to open a mobile account?
Short video platform development, relying on drawerlayout to achieve side sliding menu effect
AS400 API 从零到一的整个历程
In the fourth week of June, the list - flying melon data up main growth ranking list (BiliBili platform) was released!
@ConfigurationProperties和@Value的区别
How to maintain efficient collaboration in remote office and achieve stable growth of projects | community essay solicitation
Leetcode (524) -- match the longest word in the dictionary by deleting letters
SWT / anr problem - anr/je causes SWT
Desai wisdom number - other charts (parallel coordinate chart): employment of fresh majors in 2021
Alphabet rearrange inator 3000 (dictionary tree custom sorting)
Laravel event & Monitoring
SWT / anr problem - SWT caused by too long dump time
端口号和进程号的区别?
Live shopping mall source code, realize left-right linkage of commodity classification pages
SWT / anr issues - ams/wms
AS400 entretien d'usine