首页 > 解决方案 > HAProxy, PGSQL with SSL and multiple clusters under single port

问题描述

在我的用例中,我使用 SSL 连接到 PG 节点,因为我不想让 SSL 终止,所以我被锁定使用 TCP 模式。

使用 TCP 模式,我无法访问标头信息,尤其是主机。因此,我不能使用类似的东西

# Primary - RW
frontend PGSQL_primary
    bind *:5432

    acl host_pglab hdr(host) -i pglab-db.local
    acl host_stage hdr(host) -i stage-db.local

    use_backend cluster_pglab-primary if host_pglab
    use_backend cluster_stage-primary if host_stage

backend cluster_pglab-primary
    option httpchk OPTIONS /master
    http-check expect status 200
    default-server inter 2s fall 2 rise 2 on-marked-down shutdown-sessions
    server pglab-db-01 pglab-db-01.local:5432 maxconn 100 check check-ssl verify none port 8008
    server pglab-db-02 pglab-db-02.local:5432 maxconn 100 check check-ssl verify none port 8008

backend cluster_stage-primary
    option httpchk OPTIONS /master
    http-check expect status 200
    default-server inter 2s fall 2 rise 2 on-marked-down shutdown-sessions
    server pglab-db-01 stage-db-01.local:5432 maxconn 100 check check-ssl verify none port 8008
    server pglab-db-02 stage-db-02.local:5432 maxconn 100 check check-ssl verify none port 8008

从客户端连接到端口 5432 并将流量重定向到pglab阶段集群的主节点,具体取决于主机名。

是否有一些替代方案,我可以避免为每个集群使用新端口?

标签: postgresqlhaproxy

解决方案


我认为您可能需要像pgbouncerpgpool这样的协议感知代理。

在这两者中,我应该认为 pgbouncer 在意图和使用上更接近 haproxy。


推荐阅读