Apache-2.2

HaProxy - 502 Bad Gateway:在 HTTPS 埠上使用 HTTP

  • August 13, 2015

我會盡力解釋我的問題。

我正在研究 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

但問題仍然在這裡。如果有人可以幫助我!

謝謝

您需要告訴 HAproxy 後端伺服器正在使用 SSL:

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

“驗證無”部分告訴 haproxy 不要驗證證書鏈。我已經包含了它,但它可能不是必需的。

除非您想要它們,否則您不應該需要您指定的任何標題行。

引用自:https://serverfault.com/questions/713968