HAproxy ssl重新encryption和http头修改

我想在我的https服务器之前使用我的Haproxy 1.6.5作为Https负载均衡器,但我坚持了一个误解的问题。

我想要这样的行为:haproxy是可用的https://example.com但在它后面有几个https服务器与自签名证书,我不能切换öhttp。

所以我configuration我的tcp前端为此

frontend tcp_in mode tcp option tcplog bind *:443 ssl crt /etc/ssl/certs/server.bundle.pem maxconn 50000 tcp-request inspect-delay 5s tcp-request content accept if { req.ssl_hello_type 1 } acl example_acl req.ssl_sni -i example.com use_backend special_example if example_acl 

在此之后,我想发送我的stream量到后端之一,但重点是我想从后端请求https:\ eimA.customer.local和https:\ eimB.customer.local fro,backend2我的猜测是我需要在请求中重写主机头(可能它不会在tcp模式下工作,那么我怎样才能修改configuration来做到这一点)

我的后端configuration是:

 backend special_eims mode tcp option tcplog balance roundrobin stick-table type binary len 32 size 30k expire 30m acl clienthello req_ssl_hello_type 1 acl serverhello rep_ssl_hello_type 2 tcp-request inspect-delay 5s tcp-request content accept if clienthello tcp-response content accept if serverhello server eim1 eimA.customer.local:443 check server eim2 eimA.customer.local:443 check stick on payload_lv(43,1) if clienthello stick store-response payload_lv(43,1) if serverhello 

由于我的configuration我在浏览器中收到ssl连接错误

 curl -v https://example.com/default -k * About to connect() to example.com port 443 (#0) * Trying 127.0.0.1... connected * Connected to example.com (127.0.0.1) port 443 (#0) * Initializing NSS with certpath: sql:/etc/pki/nssdb * warning: ignoring value of ssl.verifyhost * NSS error -12263 * Closing connection #0 * SSL connect error curl: (35) SSL connect error 

使用https:// ip-address / default直接连接到后端服务器将返回404错误,因此只允许https://eimA.customer.local/default格式。

请帮忙,对不起,如果这个问题是愚蠢的。

一段时间后我解决了。 1.我从tcp切换到http模式,因为在tcp模式下你不能得到http头信息。 2.在服务器语句中使用真正的域名,并使用http-send-name-header Host ,在主机server指令3之后基本上将主机头设置为名称。对于重新encryption模式,前端证书是必需的。

  frontend CUIC_frontend mode http bind *:443 ssl crt /etc/ssl/certs/ssl-cert.pem option forwardfor option http-server-close reqadd X-Forwarded-Proto:\ https default_backend App_Backend .... backend App_Backend mode http balance roundrobin http-send-name-header Host server full-application1-domain-name 10.10.10.1:443 cookie app1 check ssl verify none server full-application2-domain-name 10.10.10.2:443 cookie app2 check ssl verify none