diff --git a/CHANGELOG.md b/CHANGELOG.md index bc87ace..e30ac26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog +## 2020-03-26 (1.8-1.5) + +- Add HTTPCHK_HOST variable to allow health check to include "Host: xyz.com" HTTP Header. Defaults to "localhost" + ## 2019-11-28 (1.8-1.5) - Add COOKIES_PARAMS variable to give the possibility to add expiration time to cookies diff --git a/haproxy/Readme.md b/haproxy/Readme.md index da77b00..b35acc4 100644 --- a/haproxy/Readme.md +++ b/haproxy/Readme.md @@ -147,6 +147,7 @@ either when running the container or in a `docker-compose.yml` file. * `TIMEOUT_CLIENT` timeouts apply when the client is expected to acknowledge or send data during the TCP process. Default `50000` ms * `TIMEOUT_SERVER` timeouts apply when the server is expected to acknowledge or send data during the TCP process. Default `50000` ms * `HTTPCHK` The HTTP method and uri used to check on the servers health - default `HEAD /` + * `HTTPCHK_HOST` Host Header override on http Health Check - default `localhost` * `INTER` parameter sets the interval between two consecutive health checks. If not specified, the default value is `2s` * `FAST_INTER` parameter sets the interval between two consecutive health checks when the server is any of the transition state (read above): UP - transitionally DOWN or DOWN - transitionally UP. If not set, then `INTER` is used. * `DOWN_INTER` parameter sets the interval between two consecutive health checks when the server is in the DOWN state. If not set, then `INTER` is used. diff --git a/haproxy/docker-entrypoint.sh b/haproxy/docker-entrypoint.sh index b6e956b..c27bdb0 100755 --- a/haproxy/docker-entrypoint.sh +++ b/haproxy/docker-entrypoint.sh @@ -45,6 +45,7 @@ if ! test -e /etc/haproxy/haproxy.cfg; then if [ ! -z "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi if [ ! -z "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi if [ ! -z "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi + if [ ! -z "$HTTPCHK_HOST" ]; then echo "export HTTPCHK_HOST=\"$HTTPCHK_HOST\"" >> /etc/environment; fi if [ ! -z "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi if [ ! -z "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi if [ ! -z "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi diff --git a/haproxy/src/configure.py b/haproxy/src/configure.py index ce09aed..95ec1bb 100644 --- a/haproxy/src/configure.py +++ b/haproxy/src/configure.py @@ -28,6 +28,7 @@ TIMEOUT_CLIENT = os.environ.get('TIMEOUT_CLIENT', '50000') TIMEOUT_SERVER = os.environ.get('TIMEOUT_SERVER', '50000') HTTPCHK = os.environ.get('HTTPCHK', 'HEAD /') +HTTPCHK_HOST = os.environ.get('HTTPCHK_HOST', 'localhost') INTER = os.environ.get('INTER', '2s') FAST_INTER = os.environ.get('FAST_INTER', INTER) DOWN_INTER = os.environ.get('DOWN_INTER', INTER) @@ -81,7 +82,7 @@ option forwardfor http-request set-header X-Forwarded-Port %[dst_port] http-request add-header X-Forwarded-Proto https if { ssl_fc } - option httpchk $httpchk HTTP/1.1\\r\\nHost:localhost + option httpchk $httpchk HTTP/1.1\\r\\nHost:$httpchk_host """) backend_conf_plus = Template(""" @@ -107,7 +108,8 @@ if BACKENDS_MODE == 'http': backend_conf += backend_type_http.substitute( - httpchk=HTTPCHK + httpchk=HTTPCHK, + httpchk_host=HTTPCHK_HOST ) ################################################################################