HaProxy – 502错误的网关:在HTTPS端口上使用HTTP

我会尽力解释我的问题。

我正在HaProxy 1.5.8 / apache 2.2上工作,我尝试做一些SSLconfiguration,但是我失败了,失败了,失败了。

我们来看看一些日志:

Haproxy日志

Aug 13 17:00:28 localhost haproxy[10930]: xxxx - - [13/Aug/2015:15:00:28 +0000] "URLxxxxx HTTP/1.1" 502 +656 "" "" 50567 131 "FT-https-in~" "BK-https-out" "myserver-https" 13 0 1 -1 +17 PH-- 0 0 0 0 0 0 0 "" "" 

Apache错误日志

 [Thu Aug 13 17:02:38 2015] [debug] ssl_engine_kernel.c(1903): OpenSSL: Exit: error in SSLv2/v3 read client hello A [Thu Aug 13 17:02:38 2015] [info] [client haproxy-server] SSL handshake failed: HTTP spoken on HTTPS port; trying to send HTML error page [Thu Aug 13 17:02:38 2015] [info] SSL Library Error: 336027804 error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request speaking HTTP to HTTPS port!? 

我的HaProxyconfiguration:

 # - Frontend - HTTPS in frontend FT-https-in bind *:443 ssl crt /etc/haproxy/ssl/my_cert.pem log global option forwardfor except 127.0.0.1 option httplog clf option log-separate-errors option logasap redirect scheme https if !{ ssl_fc } default_backend BK-https-out # - Backend - HTTPS out backend BK-https-out mode http option forwardfor except 127.0.0.1/8 header X-Forwarded-For log global option httplog clf option tcplog option http-pretend-keepalive option http-server-close # pool de serveur du backend server myserver-https xxxx:443 check 

我试图解决我的问题与头configuration如:

  http-request set-header X-Forwarded-Port %[dst_port] http-request add-header X-Forwarded-Proto https if { ssl_fc } http-request add-header X-Proto https if { ssl_fc } http-request set-header X-SSL %[ssl_fc] 

我的文件是这样构build的:crt / key / bundle

但问题仍在这里。 如果有人可以有一个想法来帮助我!

谢谢

您需要告诉HAproxy后端服务器正在使用SSL:

 server myserver-https xxxx:443 ssl check verify none 

'verify none'部分告诉haproxy不要validation证书链。 我已经包括它,但可能没有必要。

你不应该需要你指定的任何标题行,除非你想要它们。