diff --git a/caddy/parse/parsing.go b/caddy/parse/parsing.go index 482d84286..b5294de50 100644 --- a/caddy/parse/parsing.go +++ b/caddy/parse/parsing.go @@ -338,7 +338,12 @@ func standardAddress(str string) (address, error) { // repeated or conflicting scheme is confusing, so error if scheme != "" && (port == "http" || port == "https") { - return address{}, fmt.Errorf("[%s] scheme specified twice in address", str) + return address{}, fmt.Errorf("[%s] scheme specified twice in address", input) + } + + // error if scheme and port combination violate convention + if (scheme == "http" && port == "443") || (scheme == "https" && port == "80") { + return address{}, fmt.Errorf("[%s] scheme and port violate convention", input) } // standardize http and https ports to their respective port numbers diff --git a/caddy/parse/parsing_test.go b/caddy/parse/parsing_test.go index 8533b2a38..462cd40fe 100644 --- a/caddy/parse/parsing_test.go +++ b/caddy/parse/parsing_test.go @@ -27,6 +27,8 @@ func TestStandardAddress(t *testing.T) { {`:https`, "https", "", "443", false}, {`http://localhost:https`, "", "", "", true}, // conflict {`http://localhost:http`, "", "", "", true}, // repeated scheme + {`http://localhost:443`, "", "", "", true}, // not conventional + {`https://localhost:80`, "", "", "", true}, // not conventional {`http://localhost`, "http", "localhost", "80", false}, {`https://localhost`, "https", "localhost", "443", false}, {`http://127.0.0.1`, "http", "127.0.0.1", "80", false},