This commit is contained in:
andrew 2024-04-16 20:07:05 -04:00 committed by GitHub
commit 650a7b71c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,7 @@ var (
errLastRuleNotCatchAll = errors.New("The last ingress rule must match all URLs (i.e. it should not have a hostname or path filter)")
errBadWildcard = errors.New("Hostname patterns can have at most one wildcard character (\"*\") and it can only be used for subdomains, e.g. \"*.example.com\"")
errHostnameContainsPort = errors.New("Hostname cannot contain a port")
errHostnameContainsScheme = errors.New("Hostname cannot contain a scheme (e.g. http://, https://, etc.)")
ErrURLIncompatibleWithIngress = errors.New("You can't set the --url flag (or $TUNNEL_URL) when using multiple-origin ingress rules")
)
@ -359,6 +360,10 @@ func validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginReq
}
func validateHostname(r config.UnvalidatedIngressRule, ruleIndex, totalRules int) error {
// Ensure the hostname doesn't contain a scheme so a less confusing error is returned.
if u, e := url.Parse(r.Hostname); e == nil && isHTTPService(u) {
return errHostnameContainsScheme
}
// Ensure that the hostname doesn't contain port
_, _, err := net.SplitHostPort(r.Hostname)
if err == nil {