@marcel91200 / caddy Mirror · read-only / commits / 4943a4fc
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 10:45 UTC

reverseproxy: Add placeholder for networkAddr in active health check headers (#6450)

Co-authored-by: Francis Lavoie <lavofr@gmail.com>

schultzie committed Jul 9, 2024 at 11:08 UTC 4943a4fc527f41e32c1770164b00980b4226f7c7
1 file changed +3 -3
modules/caddyhttp/reverseproxy/healthchecks.go
+3 -3
@@ -312,7 +312,7 @@ func (h *Handler) doActiveHealthCheckForAllHosts() {
312 // so use a fake Host value instead; unix sockets are usually local
313 hostAddr = "localhost"
314 }
315 - err = h.doActiveHealthCheck(DialInfo{Network: addr.Network, Address: dialAddr}, hostAddr, upstream)
315 + err = h.doActiveHealthCheck(DialInfo{Network: addr.Network, Address: dialAddr}, hostAddr, networkAddr, upstream)
316 if err != nil {
317 h.HealthChecks.Active.logger.Error("active health check failed",
318 zap.String("address", hostAddr),
@@ -330,7 +330,7 @@ func (h *Handler) doActiveHealthCheckForAllHosts() {
330 // according to whether it passes the health check. An error is
331 // returned only if the health check fails to occur or if marking
332 // the host's health status fails.
333 -func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstream *Upstream) error {
333 +func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, networkAddr string, upstream *Upstream) error {
334 // create the URL for the request that acts as a health check
335 u := &url.URL{
336 Scheme: "http",
@@ -386,7 +386,7 @@ func (h *Handler) doActiveHealthCheck(dialInfo DialInfo, hostAddr string, upstre
386
387 // set headers, using a replacer with only globals (env vars, system info, etc.)
388 repl := caddy.NewReplacer()
389 - repl.Set("http.reverse_proxy.active.target_host", hostAddr)
389 + repl.Set("http.reverse_proxy.active.target_upstream", networkAddr)
390 for key, vals := range h.HealthChecks.Active.Headers {
391 key = repl.ReplaceAll(key, "")
392 if key == "Host" {