Explicitly set Host header in health checks
By default haproxy does not set any header when performing healthcheck
requests[1].
Ideally this would be fine, since HTTP/1.0 protocol does not require
`Host` header as mandatory, however different HTTP server
implementations might not strictly adhere to this specification.
This is the case of jetty-9.4.32.v20200930, which is used in gerrit
stable-3.3.
Always set the Host header when performing http healthchecks so that
they succeed regardless the target's implementation of the HTTP
protocol.
[1]https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#option%20httpchk
Bug: Issue 13732
Change-Id: I050ad61bc8c85b95e107af411dcec10850967619
diff --git a/dual-master/haproxy/haproxy.cfg.template b/dual-master/haproxy/haproxy.cfg.template
index 08536ac..6d8c458 100644
--- a/dual-master/haproxy/haproxy.cfg.template
+++ b/dual-master/haproxy/haproxy.cfg.template
@@ -39,7 +39,7 @@
balance roundrobin
option forwardfor
default-server inter 10s fall 3 rise 2
- option httpchk GET /config/server/healthcheck~status HTTP/1.0
+ option httpchk GET /config/server/healthcheck~status HTTP/1.0\r\nHost:\ $GERRIT_MASTER_1_URL
http-check expect status 200
server gerrit-1 $GERRIT_MASTER_1_URL:8080 check inter 10s
server gerrit-2 $GERRIT_MASTER_2_URL:8080 check inter 10s backup
@@ -57,7 +57,7 @@
backend ssh
mode tcp
option redispatch
- option httpchk GET /config/server/healthcheck~status HTTP/1.0
+ option httpchk GET /config/server/healthcheck~status HTTP/1.0\r\nHost:\ $GERRIT_MASTER_1_URL
http-check expect status 200
balance source
timeout connect 10s