私はMySQLのバックエンドであるいくつかのWebサーバーを持っています。 HAProxyはこれらのWebサーバーの前にあります。すべてのWebサーバーがhttpsを使用しています。HAProxy httpでsslがオンになっていますか?
httpとhttpsの両方でhttpチェックオプションを使用して、データベース接続が失われた場合、HAProxyが別のノードにフェイルオーバーすることを確認しようとしました。私のhaproxy設定ファイル:
global
log /dev/log local0
maxconn 4096
#debug
#quiet
user haproxy
group haproxy
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen http
bind *:80
mode http
balance roundrobin
stats enable
stats auth haproxy:haproxy
cookie JSESSIONID prefix
stick on src table https
option http-server-close
option forwardfor
default-server inter 5s fall 2
option httpchk
http-check expect ! string Database\ error
server sitea 192.168.0.20 cookie sitea check port 80
server siteb 192.168.0.21 cookie siteb check port 80
listen https
bind *:443
mode tcp
balance roundrobin
stick-table type ip size 5000k expire 2h store conn_cur
stick on src
option tcplog
option ssl-hello-chk
default-server inter 5s fall 2
option httpchk
http-check expect ! string Database\ error
server sitea 192.168.0.20:443 check ssl verify none
server siteb 192.168.0.21:443 check ssl verify none
最後の2行を見てください。 "ssl verify none"を指定した場合、私のHAProxyはApacheとMySQLの両方の状態を正常に確認できます。ただし、https経由でウェブページを開くことはできません(このサイトは安全な接続を提供できません。ERR_SSL_PROTOCOL_ERROR)。
このパラメータを削除すると、Webページを再び開くことができますが、すべてのhttpsサーバのステータスはHAProxyでDOWNになります。
P.S.私はまだテスト中ですので、私は現在自己署名証明書を使用しています。
バックエンドを直接テストします。 HAProxyは 'mode tcp'になっているので、問題はそれらと一緒にいるように見えます。 –
バックエンドは完全に機能します。これは、haproxyがSSL接続をリダイレクトできなかったためです。 – NeilWang