HaProxy - 502 Bad Gateway:HTTP 在 HTTPS 端口上发出

HaProxy - 502 Bad Gateway:HTTP 在 HTTPS 端口上发出

我将尽力解释我的问题。

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

让我们看一些日志:

Haproxy 日志

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

但问题仍然存在。如果有人能帮我出出主意就好了!

谢谢

答案1

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

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

“verify none”部分告诉 haproxy 不要验证证书链。我已经包含了它,但可能没有必要。

除非您需要,否则您不需要您所指示的任何标题行。

相关内容