mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-30 10:35:18 -04:00
reverseproxy: Caddyfile health check headers, host header support (#3948)
* reverse_proxy: 1.health check headers can be set through Caddyfile using health_headers directive; 2.health check header host can be set properly * reverse_proxy: replace example with syntax definition inline health_headers directive parse function * bugfix: change caddyfile_adapt testcase file from space to tab * reverseproxy: modify health_header value document as optional and add more test cases
This commit is contained in:
@@ -63,6 +63,9 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
|
||||
// health_timeout <duration>
|
||||
// health_status <status>
|
||||
// health_body <regexp>
|
||||
// health_headers {
|
||||
// <field> [<values...>]
|
||||
// }
|
||||
//
|
||||
// # passive health checking
|
||||
// max_fails <num>
|
||||
@@ -313,6 +316,26 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
}
|
||||
h.HealthChecks.Active.Port = portNum
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
if h.HealthChecks == nil {
|
||||
h.HealthChecks = new(HealthChecks)
|
||||
}
|
||||
if h.HealthChecks.Active == nil {
|
||||
h.HealthChecks.Active = new(ActiveHealthChecks)
|
||||
}
|
||||
h.HealthChecks.Active.Headers = healthHeaders
|
||||
|
||||
case "health_interval":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
|
||||
Reference in New Issue
Block a user