mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-29 23:25:50 +08:00
logging: Fix default access logger (#6251)
* logging: Fix default access logger * Simplify logic, remove retry without port, reject config with port, docs * Nil check
This commit is contained in:
@ -717,13 +717,20 @@ func (s *Server) shouldLogRequest(r *http.Request) bool {
|
||||
// logging is disabled
|
||||
return false
|
||||
}
|
||||
if _, ok := s.Logs.LoggerNames[r.Host]; ok {
|
||||
|
||||
// strip off the port if any, logger names are host only
|
||||
hostWithoutPort, _, err := net.SplitHostPort(r.Host)
|
||||
if err != nil {
|
||||
hostWithoutPort = r.Host
|
||||
}
|
||||
|
||||
if _, ok := s.Logs.LoggerNames[hostWithoutPort]; ok {
|
||||
// this host is mapped to a particular logger name
|
||||
return true
|
||||
}
|
||||
for _, dh := range s.Logs.SkipHosts {
|
||||
// logging for this particular host is disabled
|
||||
if certmagic.MatchWildcard(r.Host, dh) {
|
||||
if certmagic.MatchWildcard(hostWithoutPort, dh) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user