@marcel91200 / caddy Mirror · read-only / commits / 5333c352
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 14, 00:15 UTC

reverseproxy: Fix incorrect `health_headers` Caddyfile parsing (#4485)

Fixes #4481

Francis Lavoie committed Dec 17, 2021 at 10:53 UTC 5333c3528bd2badf1676efcced322d151e3706c8
2 files changed +9 -9
caddytest/integration/caddyfile_adapt/reverse_proxy_health_headers.txt
+3 -1
@@ -7,6 +7,7 @@ reverse_proxy 127.0.0.1:65535 {
7 X-Header-Keys VbG4NZwWnipo 335Q9/MhqcNU3s2TO
8 X-Empty-Value
9 }
10 + health_uri /health
11 }
12 ----------
13 {
@@ -38,7 +39,8 @@ reverse_proxy 127.0.0.1:65535 {
39 "VbG4NZwWnipo",
40 "335Q9/MhqcNU3s2TO"
41 ]
41 - }
42 + },
43 + "uri": "/health"
44 }
45 },
46 "upstreams": [
modules/caddyhttp/reverseproxy/caddyfile.go
+6 -8
@@ -361,15 +361,13 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
361
362 case "health_headers":
363 healthHeaders := make(http.Header)
364 - for d.Next() {
365 - for d.NextBlock(0) {
366 - key := d.Val()
367 - values := d.RemainingArgs()
368 - if len(values) == 0 {
369 - values = append(values, "")
370 - }
371 - healthHeaders[key] = values
364 + for nesting := d.Nesting(); d.NextBlock(nesting); {
365 + key := d.Val()
366 + values := d.RemainingArgs()
367 + if len(values) == 0 {
368 + values = append(values, "")
369 }
370 + healthHeaders[key] = values
371 }
372 if h.HealthChecks == nil {
373 h.HealthChecks = new(HealthChecks)