diff options
author | Mohammed Al Sahaf <msaa1990@gmail.com> | 2020-09-17 04:48:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 19:48:37 -0600 |
commit | d55d50b3b3a9a8e842bb25e1ee8468587cd346f4 (patch) | |
tree | 81173152a179e4920827f80a067399dc83509830 /modules | |
parent | b95b87381a282e1fe57295d145b71645d7801f07 (diff) |
reverseproxy: Enforce port range size of 1 at provision (#3695)
* reverse_proxy: ensure upstream address has port range of only 1
* reverse_proxy: don't log the error if upstream range size is more than 1
Diffstat (limited to 'modules')
-rw-r--r-- | modules/caddyhttp/reverseproxy/reverseproxy.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index d1aa49a..910fbfc 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -204,6 +204,13 @@ func (h *Handler) Provision(ctx caddy.Context) error { // set up upstreams for _, upstream := range h.Upstreams { + addr, err := caddy.ParseNetworkAddress(upstream.Dial) + if err != nil { + return err + } + if addr.PortRangeSize() != 1 { + return fmt.Errorf("multiple addresses (upstream must map to only one address): %v", addr) + } // create or get the host representation for this upstream var host Host = new(upstreamHost) existingHost, loaded := hosts.LoadOrStore(upstream.String(), host) |