From 51f35ba03f78e691d0e141b24ff19f82bfb34b67 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 3 Mar 2021 12:12:31 -0500 Subject: reverseproxy: Fix upstreams with placeholders with no port (#4046) --- modules/caddyhttp/reverseproxy/caddyfile.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'modules') 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 } -- cgit v1.2.3