HaProxy - 502 Bad Gateway:HTTPS端口上的HTTP

Modified on: Sat, 09 Nov 2019 00:40:02 +0800

我会尝试解释我的问题。

我正在使用HaProxy 1.5.8 / apache 2.2,我尝试进行一些SSL配置,但是我失败了,失败了,失败了。

让我们看一些日志:

Haproxy Logs

Aug 13 17:00:28 localhost haproxy[10930]: x.x.x.x - - [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!?

我的HaProxy配置:

# - 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 x.x.x.x:443 check

我尝试使用标头配置修复我的问题,如:

 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]

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

但问题仍然存在。
如果有人有想法帮助我!

由于

作者:Ze.Miw

最佳答案

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

server myserver-https x.x.x.x:443 ssl check verify none

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

除非您需要,否则您不需要任何标题行。

作者:Jim G.

相关问答

添加新评论