Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverse_proxy: Configurable request headers on active health checks
See https://caddy.community/t/health-check-user-agent/6309
Matthew Holt committed
Oct 4, 2019 at 17:21 UTC
44cb804b9e5bc2779cf971862c37a1e3b4671e26
1 file changed
+4
modules/caddyhttp/reverseproxy/healthchecks.go
+4
@@ -43,6 +43,7 @@ type HealthChecks struct {
43
type ActiveHealthChecks struct {
44
Path string `json:"path,omitempty"`
45
Port int `json:"port,omitempty"`
46
+ Headers http.Header `json:"headers,omitempty"`
47
Interval caddy.Duration `json:"interval,omitempty"`
48
Timeout caddy.Duration `json:"timeout,omitempty"`
49
MaxSize int64 `json:"max_size,omitempty"`
@@ -163,6 +164,9 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, host H
164
if err != nil {
165
return fmt.Errorf("making request: %v", err)
166
}
167
+ for key, hdrs := range h.HealthChecks.Active.Headers {
168
+ req.Header[key] = hdrs
169
+ }
170
171
// do the request, being careful to tame the response body
172
resp, err := h.HealthChecks.Active.httpClient.Do(req)