【问题标题】:Haproxy 1.4 connecting to an https backend serversHaproxy 1.4 连接到 https 后端服务器
【发布时间】:2013-09-02 05:48:19
【问题描述】:

我正在尝试使用端口 443 通过 https 连接到 2 个后端服务器,并且我想找到一种将密钥和证书文件发送到后端服务器的方法。我的 haproxy.cfg 是:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy
    daemon
    #debug
    #quiet

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

listen stats :8000
    #mode http
    stats enable
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth admin:password


listen  ssl-relay :80
    mode tcp
    balance roundrobin
    stick-table type ip size 200m expire 30m
    stick on src
    server  server01 www.example.com:443 check inter 2000 fall 3
    server  server02 www.example.com:443 check inter 2000 fall 3

我们怎样才能使haproxy服务器和后端服务器之间的通信安全???

【问题讨论】:

    标签: ubuntu ssl https openssl haproxy


    【解决方案1】:

    您的客户会使用https://myfakepage.com:80 作为网址吗?如果不是,那么你所做的在很大程度上是毫无意义的。您正在处理与前端的未加密连接,然后是与后端的加密连接。问题是当连接回到客户端时,它将是未加密的,所以你不会给自己买任何东西。如果您的客户将使用https://pmyfakepage.com:80,则无需执行任何操作,因为 haproxy 已经充当了 https 流量的传递。

    您是否尝试在负载平衡器上执行 SSL 终止,如果是,您正在向后执行

    你的绑定部分看起来像

    frontend ssl-site
    bind *:443 ssl crt /path/to/bundle.pem  #you need to make sure the whole cert path is in one pem file
    reqadd X-Forwarded-Proto:\ https
    default_backend myServers
    
    backend myServers
    balance roundrobin
    server server1 www.example.com:80
    server server2 www2.example.com:80
    

    但正如 dtorgo 所说,以这种方式终止 ssl 仅适用于 1.5 及更高版本。如果您发现 stunnel 太慢,另一种选择是 stud。

    希望这能为你解决问题。

    【讨论】:

      【解决方案2】:

      haproxy 1.4 不支持 SSL。要么更新到 1.5,要么考虑使用类似 stunnel 的东西。

      我在一个非常大的企业实施中都使用了这两种产品,并且两种产品都运行良好。如果您想坚持使用 haproxy 1.4,那么 stunnel 路线非常容易。只需在您的 haproxy 服务器上安装 stunnel,侦听本地端口,让 haproxy 连接到该本地端口,然后将 stunnel 配置为指向远程 https 端点。除了 stunnel 中的全局设置,实际的配置是 3 行

      1. 姓名
      2. 在 localhost 上监听端口
      3. 目标主机和端口

      【讨论】:

        猜你喜欢
        • 2018-07-29
        • 1970-01-01
        • 2017-12-20
        • 1970-01-01
        • 2012-12-27
        • 2020-06-26
        • 1970-01-01
        • 1970-01-01
        • 2016-03-13
        相关资源
        最近更新 更多