mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 10:13:39 +08:00
When the requested host is not found log the remote host.
This commit is contained in:
parent
79db939259
commit
f4fcfa8793
|
@ -337,6 +337,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
}
|
||||
|
||||
// Get the remote host
|
||||
remoteHost, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
remoteHost = r.RemoteAddr
|
||||
}
|
||||
|
||||
if vh, ok := s.vhosts[host]; ok {
|
||||
status, _ := vh.stack.ServeHTTP(w, r)
|
||||
|
||||
|
@ -347,7 +353,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
} else {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
fmt.Fprintf(w, "No such host at %s", s.Server.Addr)
|
||||
log.Printf("[INFO] %s - No such host at %s", host, s.Server.Addr)
|
||||
log.Printf("[INFO] %s - No such host at %s (requested by %s)", host, s.Server.Addr, remoteHost)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user