summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/healthchecks.go
diff options
context:
space:
mode:
authoryaxin <yaxin.me@gmail.com>2021-01-05 02:26:18 +0800
committerGitHub <noreply@github.com>2021-01-04 11:26:18 -0700
commit3c9256a1bea79a542500c8d07a9fd06fa806a79e (patch)
treec3710568f568388641eb1a7aac904edb205a4f2c /modules/caddyhttp/reverseproxy/healthchecks.go
parent7846bc1e06b2de97906cd562d16db4b2aafbd74b (diff)
reverseproxy: Caddyfile health check headers, host header support (#3948)
* reverse_proxy: 1.health check headers can be set through Caddyfile using health_headers directive; 2.health check header host can be set properly * reverse_proxy: replace example with syntax definition inline health_headers directive parse function * bugfix: change caddyfile_adapt testcase file from space to tab * reverseproxy: modify health_header value document as optional and add more test cases
Diffstat (limited to 'modules/caddyhttp/reverseproxy/healthchecks.go')
-rw-r--r--modules/caddyhttp/reverseproxy/healthchecks.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/healthchecks.go b/modules/caddyhttp/reverseproxy/healthchecks.go
index 285834b..42003b6 100644
--- a/modules/caddyhttp/reverseproxy/healthchecks.go
+++ b/modules/caddyhttp/reverseproxy/healthchecks.go
@@ -26,6 +26,7 @@ import (
"regexp"
"runtime/debug"
"strconv"
+ "strings"
"time"
"github.com/caddyserver/caddy/v2"
@@ -241,7 +242,11 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, host H
return fmt.Errorf("making request: %v", err)
}
for key, hdrs := range h.HealthChecks.Active.Headers {
- req.Header[key] = hdrs
+ if strings.ToLower(key) == "host" {
+ req.Host = h.HealthChecks.Active.Headers.Get(key)
+ } else {
+ req.Header[key] = hdrs
+ }
}
// do the request, being careful to tame the response body