HAProxy:检测SSL连接内容,然后决定是否转发

我希望在端口443有一个HAProxy的前端。这个前端的作用如下:

它解密连接的内容并检查:

1-如果连接的encryption内容是ssh,即如果数据包的第一个字是SSH-2.0 ,那么它将解密的数据包转发到端口22.我认为这样的后端看起来像这样:

 backend ssh mode tcp option tcplog server ssh 127.0.0.1:22 timeout server 2h 

2-如果encryption内容是其他内容,则将encryption内容转发到端口8443,其中包含具有正确SNI密钥的Apache服务器。 如果必须为每个url包含所有正确的SNI密钥(为了避免出现中间人攻击,你能告诉我怎么用这个例子吗?我没有问题所有的钥匙HAProxy。

为什么? 因为我已经有了端口443上的apache。我想把它移动到其他一些端口,而不必重写我的整个configuration。 所以我想把它移动到端口8443例如,然后告诉HAProxy,如果连接不是SSH,那么只是转发你到达端口443的所有东西。

我怎么写这样的前端+后端? 请协助。

我目前有以下前端作为起点:

 frontend ssl bind 0.0.0.0:443 ssl crt /home/myuser/SSL/certs.pem no-sslv3 #decrypts the connection with the keys certs.pem mode tcp option tcplog tcp-request inspect-delay 5s tcp-request content accept if HTTP acl client_attempts_ssh payload(0,7) -m bin 5353482d322e30 #if the decrypted information starts with SSH-2.0 use_backend ssh if client_attempts_ssh #forward to SSH if condition client_attempts_ssh is satisfied. use_backend forwardToApache if !client_attempts_ssh 

请询问你是否需要任何额外的细节。

谢谢。

您可以先使用SNI,然后select

 site1.domain.com, site2.domain.com, 

要么

 ssh.domain.com 

并且只有当你selectssh.domain.com进行解密时,执行ssh magic并将其发送到未encryption的本地web服务器,假设这看起来像普通的httpsstream量,但是不包含https内容中的敏感信息,因为这是由site1和site2处理的。