summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-10-04 17:21:38 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-10-04 17:21:38 -0600
commit44cb804b9e5bc2779cf971862c37a1e3b4671e26 (patch)
tree1b9f3a899ea9e11144b25e6c2462ed2b62db4f14
parentc11e3bffd698cfb1e19a21097ff4a65cf10e28b0 (diff)
reverse_proxy: Configurable request headers on active health checks
See https://caddy.community/t/health-check-user-agent/6309
-rw-r--r--modules/caddyhttp/reverseproxy/healthchecks.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/healthchecks.go b/modules/caddyhttp/reverseproxy/healthchecks.go
index 084a693..be532ea 100644
--- a/modules/caddyhttp/reverseproxy/healthchecks.go
+++ b/modules/caddyhttp/reverseproxy/healthchecks.go
@@ -43,6 +43,7 @@ type HealthChecks struct {
type ActiveHealthChecks struct {
Path string `json:"path,omitempty"`
Port int `json:"port,omitempty"`
+ Headers http.Header `json:"headers,omitempty"`
Interval caddy.Duration `json:"interval,omitempty"`
Timeout caddy.Duration `json:"timeout,omitempty"`
MaxSize int64 `json:"max_size,omitempty"`
@@ -163,6 +164,9 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, host H
if err != nil {
return fmt.Errorf("making request: %v", err)
}
+ for key, hdrs := range h.HealthChecks.Active.Headers {
+ req.Header[key] = hdrs
+ }
// do the request, being careful to tame the response body
resp, err := h.HealthChecks.Active.httpClient.Do(req)