haproxy同一端口配置多域名SSL

1、一般我们会有key,crt文件,把这两个文件合并成以下格式

-----BEGIN RSA PRIVATE KEY-----
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
frontend main
    bind *:80
    bind *:443 ssl crt /cert/haproxy/X1.pem  crt /cert/haproxy/X2.pem   crt /cert/haproxy/X3.pem
    mode http

    #http重定向https
    redirect scheme https code 301 if !{ ssl_fc }
    use_backend x1 if { ssl_fc_sni 域名1 }
    use_backend x2 if { ssl_fc_sni 域名2 }
    use_backend x3 if { ssl_fc_sni 域名3 }

backend x1
    mode http
    #支持NTLM认证,在defaults中 需要移除http-server-close
    option http-keep-alive
    http-reuse always

    server  app1  192.168.0.78:80
backend x2
    mode http
    server  app2  192.168.0.73:80
backend x3
    mode http
    server  app3  192.168.0.71:80