Skip to content

Commit

Permalink
reverseproxy: Fix incorrect health_headers Caddyfile parsing (#4485)
Browse files Browse the repository at this point in the history
Fixes #4481
  • Loading branch information
francislavoie authored Dec 17, 2021
1 parent 180ae0c commit 5333c35
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ reverse_proxy 127.0.0.1:65535 {
X-Header-Keys VbG4NZwWnipo 335Q9/MhqcNU3s2TO
X-Empty-Value
}
health_uri /health
}
----------
{
Expand Down Expand Up @@ -38,7 +39,8 @@ reverse_proxy 127.0.0.1:65535 {
"VbG4NZwWnipo",
"335Q9/MhqcNU3s2TO"
]
}
},
"uri": "/health"
}
},
"upstreams": [
Expand Down
14 changes: 6 additions & 8 deletions modules/caddyhttp/reverseproxy/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,15 +361,13 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {

case "health_headers":
healthHeaders := make(http.Header)
for d.Next() {
for d.NextBlock(0) {
key := d.Val()
values := d.RemainingArgs()
if len(values) == 0 {
values = append(values, "")
}
healthHeaders[key] = values
for nesting := d.Nesting(); d.NextBlock(nesting); {
key := d.Val()
values := d.RemainingArgs()
if len(values) == 0 {
values = append(values, "")
}
healthHeaders[key] = values
}
if h.HealthChecks == nil {
h.HealthChecks = new(HealthChecks)
Expand Down

0 comments on commit 5333c35

Please sign in to comment.