mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-13 17:26:46 +00:00
reverseproxy: Customizable dial network for SRV upstreams
By request of a sponsor
This commit is contained in:
parent
935b09de83
commit
3bb22672f9
2 changed files with 9 additions and 0 deletions
|
|
@ -1528,6 +1528,7 @@ func (u *SRVUpstreams) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
|||
return d.Errf("bad delay value '%s': %v", d.Val(), err)
|
||||
}
|
||||
u.FallbackDelay = caddy.Duration(dur)
|
||||
|
||||
case "grace_period":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
|
|
|
|||
|
|
@ -70,6 +70,11 @@ type SRVUpstreams struct {
|
|||
// A negative value disables this.
|
||||
FallbackDelay caddy.Duration `json:"dial_fallback_delay,omitempty"`
|
||||
|
||||
// Specific network to dial when connecting to the upstream(s)
|
||||
// provided by SRV records upstream. See Go's net package for
|
||||
// accepted values. For example, to restrict to IPv4, use "tcp4".
|
||||
DialNetwork string `json:"dial_network,omitempty"`
|
||||
|
||||
resolver *net.Resolver
|
||||
|
||||
logger *zap.Logger
|
||||
|
|
@ -177,6 +182,9 @@ func (su SRVUpstreams) GetUpstreams(r *http.Request) ([]*Upstream, error) {
|
|||
)
|
||||
}
|
||||
addr := net.JoinHostPort(rec.Target, strconv.Itoa(int(rec.Port)))
|
||||
if su.DialNetwork != "" {
|
||||
addr = su.DialNetwork + "/" + addr
|
||||
}
|
||||
upstreams[i] = Upstream{Dial: addr}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue