plugin/forward: configurable domain support for healthcheck (#5281)

* plugin/forward: configurable domain support for healthcheck

Signed-off-by: hansedong <admin@yinxiaoluo.com>
This commit is contained in:
hansedong 2022-04-13 00:39:48 +08:00 committed by GitHub
parent e60c179194
commit 0622a6c66c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 113 additions and 35 deletions

View file

@ -151,6 +151,7 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
if f.opts.forceTCP && transports[i] != transport.TLS {
f.proxies[i].health.SetTCPTransport()
}
f.proxies[i].health.SetDomain(f.opts.hcDomain)
}
return f, nil
@ -187,11 +188,17 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
return fmt.Errorf("health_check can't be negative: %d", dur)
}
f.hcInterval = dur
f.opts.hcDomain = "."
for c.NextArg() {
switch hcOpts := c.Val(); hcOpts {
case "no_rec":
f.opts.hcRecursionDesired = false
case "domain":
if !c.NextArg() {
return c.ArgErr()
}
f.opts.hcDomain = c.Val()
default:
return fmt.Errorf("health_check: unknown option %s", hcOpts)
}