Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

caddyhttp: Improve listen addr error message for IPv6 #4740

Merged
merged 1 commit into from Apr 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/caddyhttp/autohttps.go
Expand Up @@ -222,11 +222,15 @@ func (app *App) automaticHTTPSPhase1(ctx caddy.Context, repl *caddy.Replacer) er
app.logger.Info("enabling automatic HTTP->HTTPS redirects", zap.String("server_name", srvName))

// create HTTP->HTTPS redirects
for _, addr := range srv.Listen {
for _, listenAddr := range srv.Listen {
// figure out the address we will redirect to...
addr, err := caddy.ParseNetworkAddress(addr)
addr, err := caddy.ParseNetworkAddress(listenAddr)
if err != nil {
return fmt.Errorf("%s: invalid listener address: %v", srvName, addr)
msg := "%s: invalid listener address: %v"
if strings.Count(listenAddr, ":") > 1 {
msg = msg + ", there are too many colons, so the port is ambiguous. Did you mean to wrap the IPv6 address with [] brackets?"
}
return fmt.Errorf(msg, srvName, listenAddr)
}

// this address might not have a hostname, i.e. might be a
Expand Down