summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/caddyfile.go
diff options
context:
space:
mode:
authoryaxin <yaxin.me@gmail.com>2021-01-05 02:26:18 +0800
committerGitHub <noreply@github.com>2021-01-04 11:26:18 -0700
commit3c9256a1bea79a542500c8d07a9fd06fa806a79e (patch)
treec3710568f568388641eb1a7aac904edb205a4f2c /modules/caddyhttp/reverseproxy/caddyfile.go
parent7846bc1e06b2de97906cd562d16db4b2aafbd74b (diff)
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
Diffstat (limited to 'modules/caddyhttp/reverseproxy/caddyfile.go')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index 4a69287..57f425a 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -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()