From c986110678458f032018ff931273f8b6e1921e38 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 1 Feb 2021 17:02:01 -0700 Subject: httpcaddyfile: Warn if site address uses unspecified IP (close #4004) --- caddyconfig/httpcaddyfile/httptype.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'caddyconfig') diff --git a/caddyconfig/httpcaddyfile/httptype.go b/caddyconfig/httpcaddyfile/httptype.go index 2e7dd7c..0a5149f 100644 --- a/caddyconfig/httpcaddyfile/httptype.go +++ b/caddyconfig/httpcaddyfile/httptype.go @@ -17,6 +17,7 @@ package httpcaddyfile import ( "encoding/json" "fmt" + "log" "reflect" "regexp" "sort" @@ -471,6 +472,13 @@ func (st *ServerType) serversFromPairings( hosts := sblock.hostsFromKeys(false) + // emit warnings if user put unspecified IP addresses; they probably want the bind directive + for _, h := range hosts { + if h == "0.0.0.0" || h == "::" { + log.Printf("[WARNING] Site block has unspecified IP address %s which only matches requests having that Host header; you probably want the 'bind' directive to configure the socket", h) + } + } + // tls: connection policies if cpVals, ok := sblock.pile["tls.connection_policy"]; ok { // tls connection policies -- cgit v1.2.3