Skip to content

Commit

Permalink
reverseproxy: Set origreq in active health check (#5284)
Browse files Browse the repository at this point in the history
* reverseproxy: Set origreq in active health check

Fix #5281

* Oops; dereference Request
  • Loading branch information
mholt authored Jan 6, 2023
1 parent 55035d3 commit d74f6fd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion modules/caddyhttp/reverseproxy/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)
Expand Down

0 comments on commit d74f6fd

Please sign in to comment.