aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy/healthchecks.go
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2021-03-29 20:36:40 -0400
committerGitHub <[email protected]>2021-03-29 18:36:40 -0600
commit75f797debdd6c4294497edba9889c6251a8542e7 (patch)
tree7146a299bbc84ace3df9d57ba9ac6febb984f818 /modules/caddyhttp/reverseproxy/healthchecks.go
parent1c8ea0082822fbc13cb6b86443b908f6a068f385 (diff)
downloadcaddy-75f797debdd6c4294497edba9889c6251a8542e7.tar.gz
caddy-75f797debdd6c4294497edba9889c6251a8542e7.zip
reverseproxy: Implement health_uri, deprecate health_path, supports query (#4050)
* reverseproxy: Implement health_uri, replaces health_path, supports query Also fixes a bug with `health_status` Caddyfile parsing , it would always only take the first character of the status code even if it didn't end with "xx". * reverseproxy: Rename to URI, named logger, warn in Provision (for JSON)
Diffstat (limited to 'modules/caddyhttp/reverseproxy/healthchecks.go')
-rw-r--r--modules/caddyhttp/reverseproxy/healthchecks.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/healthchecks.go b/modules/caddyhttp/reverseproxy/healthchecks.go
index 42003b647..6f6586652 100644
--- a/modules/caddyhttp/reverseproxy/healthchecks.go
+++ b/modules/caddyhttp/reverseproxy/healthchecks.go
@@ -51,9 +51,13 @@ type HealthChecks struct {
// health checks (that is, health checks which occur in a
// background goroutine independently).
type ActiveHealthChecks struct {
- // The URI path to use for health checks.
+ // The path to use for health checks.
+ // DEPRECATED: Use 'uri' instead.
Path string `json:"path,omitempty"`
+ // The URI (path and query) to use for health checks
+ URI string `json:"uri,omitempty"`
+
// The port to use (if different from the upstream's dial
// address) for health checks.
Port int `json:"port,omitempty"`
@@ -79,6 +83,7 @@ type ActiveHealthChecks struct {
// body of a healthy backend.
ExpectBody string `json:"expect_body,omitempty"`
+ uri *url.URL
httpClient *http.Client
bodyRegexp *regexp.Regexp
logger *zap.Logger
@@ -218,7 +223,15 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, host H
u := &url.URL{
Scheme: scheme,
Host: hostAddr,
- Path: h.HealthChecks.Active.Path,
+ }
+
+ // if we have a provisioned uri, use that, otherwise use
+ // the deprecated Path option
+ if h.HealthChecks.Active.uri != nil {
+ u.Path = h.HealthChecks.Active.uri.Path
+ u.RawQuery = h.HealthChecks.Active.uri.RawQuery
+ } else {
+ u.Path = h.HealthChecks.Active.Path
}
// adjust the port, if configured to be different