aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/reverseproxy/caddyfile.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/reverseproxy/caddyfile.go')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index 728bc2f88..a79bd090e 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -15,6 +15,7 @@
package reverseproxy
import (
+ "fmt"
"net/http"
"reflect"
"strconv"
@@ -157,7 +158,25 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
}
commonScheme = scheme
- h.Upstreams = append(h.Upstreams, &Upstream{Dial: dialAddr})
+ parsedAddr, err := caddy.ParseNetworkAddress(dialAddr)
+ if err != nil {
+ return d.WrapErr(err)
+ }
+
+ if parsedAddr.StartPort == 0 && parsedAddr.EndPort == 0 {
+ // unix networks don't have ports
+ h.Upstreams = append(h.Upstreams, &Upstream{
+ Dial: dialAddr,
+ })
+ } else {
+ // expand a port range into multiple upstreams
+ for i := parsedAddr.StartPort; i <= parsedAddr.EndPort; i++ {
+ h.Upstreams = append(h.Upstreams, &Upstream{
+ Dial: caddy.JoinNetworkAddress("", parsedAddr.Host, fmt.Sprint(i)),
+ })
+ }
+ }
+
return nil
}