plugin/forward: make per-upstream read timeout configurable (#8205)

This commit is contained in:
Aaron Mark
2026-07-05 03:07:04 +03:00
committed by GitHub
parent 97e3a71afb
commit ea19f815a6
4 changed files with 96 additions and 3 deletions

View File

@@ -250,6 +250,7 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
f.proxies[i].SetExpire(f.expire)
f.proxies[i].SetMaxAge(f.maxAge)
f.proxies[i].SetMaxIdleConns(f.maxIdleConns)
f.proxies[i].SetReadTimeout(f.readTimeout)
f.proxies[i].GetHealthchecker().SetRecursionDesired(f.opts.HCRecursionDesired)
// when TLS is used, checks are set to tcp-tls
if f.opts.ForceTCP && transports[i] != transport.TLS {
@@ -389,6 +390,18 @@ func parseBlock(c *caddy.Controller, f *Forward) error {
return fmt.Errorf("max_idle_conns can't be negative: %d", n)
}
f.maxIdleConns = n
case "read_timeout":
if !c.NextArg() {
return c.ArgErr()
}
dur, err := time.ParseDuration(c.Val())
if err != nil {
return err
}
if dur <= 0 {
return fmt.Errorf("read_timeout must be positive: %s", dur)
}
f.readTimeout = dur
case "doh_method":
if !c.NextArg() {
return c.ArgErr()