Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 13, 08:00 UTC
reverseproxy: Set origreq in active health check (#5284)
* reverseproxy: Set origreq in active health check Fix #5281 * Oops; dereference Request
Matt Holt committed
Jan 6, 2023 at 13:06 UTC
d74f6fd96790fc8f5abf302d9b10b0d333273d0d
1 file changed
+4
-1
modules/caddyhttp/reverseproxy/healthchecks.go
+4
-1
@@ -266,7 +266,8 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstre
266
u.Host = net.JoinHostPort(host, portStr)
267
}
268
269
- // attach dialing information to this request
269
+ // attach dialing information to this request, as well as context values that
270
+ // may be expected by handlers of this request
271
ctx := h.ctx.Context
272
ctx = context.WithValue(ctx, caddy.ReplacerCtxKey, caddy.NewReplacer())
273
ctx = context.WithValue(ctx, caddyhttp.VarsCtxKey, map[string]any{
@@ -276,6 +277,8 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstre
277
if err != nil {
278
return fmt.Errorf("making request: %v", err)
279
}
280
+ ctx = context.WithValue(ctx, caddyhttp.OriginalRequestCtxKey, *req)
281
+ req = req.WithContext(ctx)
282
for key, hdrs := range h.HealthChecks.Active.Headers {
283
if strings.ToLower(key) == "host" {
284
req.Host = h.HealthChecks.Active.Headers.Get(key)