httpcaddyfile: Warn if site address uses unspecified IP (close #4004)

This commit is contained in:
Matthew Holt 2021-02-01 17:02:01 -07:00
parent 55e49ff5c8
commit c986110678
No known key found for this signature in database
GPG key ID: 2A349DD577D586A5

View file

@ -17,6 +17,7 @@ package httpcaddyfile
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"reflect" "reflect"
"regexp" "regexp"
"sort" "sort"
@ -471,6 +472,13 @@ func (st *ServerType) serversFromPairings(
hosts := sblock.hostsFromKeys(false) 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 // tls: connection policies
if cpVals, ok := sblock.pile["tls.connection_policy"]; ok { if cpVals, ok := sblock.pile["tls.connection_policy"]; ok {
// tls connection policies // tls connection policies