Old post, but I think I solve that same problem, it was driving me crazy. The solution is to CONCATENATE a backend with a frontend, like this:
#######haproxy.cfg_BEGIN##################
…
…
frontend SSL_PassThrough
mode tcp
bind *:80
bind *:443
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }
use_backend backend1 if { req_ssl_sni -i aaa.bbb.com }
use_backend backend2 if { req_ssl_sni -i ccc.ddd.com }
use_backend bbackend3 if { req_ssl_sni -i eee.fff.com }
default_backend bk_tcp_to_https
backend bk_tcp_to_https
mode tcp
server haproxy-https 127.0.0.1:8443 check
frontend SSL_Termination
mode http
bind *:8443 ssl crt /etc/haproxy/certs/ggg.hhh.com.pem crt /etc/haproxy/certs/iii.kkk.com.pem
use_backend backend4 if { hdr(host) -i ggg.hhh.com }
use_backend backend5 if { hdr(host) -i iii.kkk.com }
#SSL Passthrough Backends (every backend manage their own SSL termiantion)
backend backend1
mode tcp
server server1 192.168.0.100:443 check
backend backend2
mode tcp
server server2 192.168.0.101:443 check
backend backend3
mode tcp
server server3 192.168.0.102:443 check
#SSL Terminated by HAProxy Backends (plain http traffic between HAProxy and these backends)
backend backend4
mode http
server server4 192.168.0.104:80 check
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
backend backend5
mode http
server server5 192.168.0.105:80 check
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
#########haproxy.cfg_END#################
The Trick here is “default_backend bk_tcp_to_https” in frontend1 that concatenates all the requests that are not going to be passthrough, to the “backend bk_tcp_to_https”.
It is basically telling if the request is not for aaa.bbb.com or ccc.ddd.com or eee.fff.com, then send it to the default backend, which is himself: 127.0.0.1 but in other port: 8443, and then, Frontend2 is listening in 8443 to take care of the termination of the SSL.
This is the mixed TCP/HTTP combination to passthrough some SSL and terminate others using one single configuration.