带有 haproxy ssl 终止的 Ejabberd

Ejabberd with haproxy ssl termination

有人成功地使用 haproxy 1.7 终止了 ejabberd + ssl 吗?

frontend ejabberd   
bind *:4000 ssl crt /etc/haproxy/certs/my-domain.com.pem
mode tcp
timeout client  3h

option tcplog

option clitcpka

default_backend ejabberd

backend ejabberd
mode tcp

timeout server  60m 

option redispatch

option srvtcpka

option independent-streams

balance leastconn

default-server inter 5s rise 3 fall 3 on-marked-down shutdown-sessions

server ejabberd localhost:5222 check slowstart 120s

没有 ssl crt 也能正常工作。我的 smack 客户给了我一个 No response received within reply timeout. Timeout was 5000ms (~5s). While waiting for establishing TLS.

我也尝试过在 ejabberd conf 上使用或不使用 ttls

我能够让准确的配置正常工作,您需要:

  1. 在 ejabberd 中禁用 tls,因为 HAProxy 正在执行 ssl 卸载并且 ejabberd 托管在同一台机器上:

    • 注释 certfile 行
    • 注释 starttls 行
  2. 正确地配置你的客户端,我用过 pidgin,但你应该可以用 smack 做同样的事情:

    • 正确配置地址和端口(这里是4000)
    • 确保您使用 "old style TLS" 而不是 STARTTLS,后者不能与 HAProxy 一起使用。

否则,如果您希望客户端使用 STARTTLS 配置,则必须配置 HAProxy 以代理 XMPP 加密流量(删除 "ssl crt .." )