summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2021-03-03 12:12:31 -0500
committerGitHub <noreply@github.com>2021-03-03 10:12:31 -0700
commit51f35ba03f78e691d0e141b24ff19f82bfb34b67 (patch)
tree46ea4954e1453b030fd2c8bccf1adfb77739885a /modules
parentad8d01cb66316cf04ea49ec277316d6f83b9abb6 (diff)
reverseproxy: Fix upstreams with placeholders with no port (#4046)
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index 71ed21f..da7450d 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -184,6 +184,13 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if network != "" {
return caddy.JoinNetworkAddress(network, host, port), nil
}
+
+ // if the host is a placeholder, then we don't want to join with an empty port,
+ // because that would just append an extra ':' at the end of the address.
+ if port == "" && strings.Contains(host, "{") {
+ return host, nil
+ }
+
return net.JoinHostPort(host, port), nil
}