reverseproxy: Fix upstreams with placeholders with no port (#4046)

This commit is contained in:
Francis Lavoie
2021-03-03 12:12:31 -05:00
committed by GitHub
parent ad8d01cb66
commit 51f35ba03f
2 changed files with 109 additions and 0 deletions
@@ -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
}