summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2023-01-06 13:06:38 -0700
committerGitHub <noreply@github.com>2023-01-06 15:06:38 -0500
commitd74f6fd96790fc8f5abf302d9b10b0d333273d0d (patch)
treea3359fb2f6ed489ba9f61875d29519983c454cf1 /modules/caddyhttp/reverseproxy
parent55035d327a2dbd32887db0b1dcbc25dba590798f (diff)
reverseproxy: Set origreq in active health check (#5284)
* reverseproxy: Set origreq in active health check Fix #5281 * Oops; dereference Request
Diffstat (limited to 'modules/caddyhttp/reverseproxy')
-rw-r--r--modules/caddyhttp/reverseproxy/healthchecks.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/healthchecks.go b/modules/caddyhttp/reverseproxy/healthchecks.go
index e4c732a..c27b24f 100644
--- a/modules/caddyhttp/reverseproxy/healthchecks.go
+++ b/modules/caddyhttp/reverseproxy/healthchecks.go
@@ -266,7 +266,8 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstre
u.Host = net.JoinHostPort(host, portStr)
}
- // attach dialing information to this request
+ // attach dialing information to this request, as well as context values that
+ // may be expected by handlers of this request
ctx := h.ctx.Context
ctx = context.WithValue(ctx, caddy.ReplacerCtxKey, caddy.NewReplacer())
ctx = context.WithValue(ctx, caddyhttp.VarsCtxKey, map[string]any{
@@ -276,6 +277,8 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstre
if err != nil {
return fmt.Errorf("making request: %v", err)
}
+ ctx = context.WithValue(ctx, caddyhttp.OriginalRequestCtxKey, *req)
+ req = req.WithContext(ctx)
for key, hdrs := range h.HealthChecks.Active.Headers {
if strings.ToLower(key) == "host" {
req.Host = h.HealthChecks.Active.Headers.Get(key)