Browse Source
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
master
Mohammed Al Sahaf
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
0 deletions
-
modules/caddyhttp/reverseproxy/reverseproxy.go
|
@ -204,6 +204,13 @@ func (h *Handler) Provision(ctx caddy.Context) error { |
|
|
|
|
|
|
|
|
// set up upstreams
|
|
|
// set up upstreams
|
|
|
for _, upstream := range h.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
|
|
|
// create or get the host representation for this upstream
|
|
|
var host Host = new(upstreamHost) |
|
|
var host Host = new(upstreamHost) |
|
|
existingHost, loaded := hosts.LoadOrStore(upstream.String(), host) |
|
|
existingHost, loaded := hosts.LoadOrStore(upstream.String(), host) |
|
|