summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2022-04-28 10:18:45 -0400
committerGitHub <noreply@github.com>2022-04-28 08:18:45 -0600
commitdcc98da4d25dc13183f4bb4e913439a160bb1adf (patch)
tree889d47dc672faac9c216a7da598f1d373c0dd56f /modules/caddyhttp
parent3ab648382d403cdfe5c0c7218fafe2b4197ccfd7 (diff)
caddyhttp: Improve listen addr error message for IPv6 (#4740)
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/autohttps.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/caddyhttp/autohttps.go b/modules/caddyhttp/autohttps.go
index f1d99ce..91611f9 100644
--- a/modules/caddyhttp/autohttps.go
+++ b/modules/caddyhttp/autohttps.go
@@ -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