mirror of
https://github.com/caddyserver/caddy.git
synced 2025-02-24 23:57:05 -05:00
Move logic to split the port to only happen when the host is not found.
This commit is contained in:
parent
f4fcfa8793
commit
2acaf2fa6f
1 changed files with 6 additions and 6 deletions
|
@ -337,12 +337,6 @@ 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)
|
||||
|
||||
|
@ -351,6 +345,12 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
DefaultErrorFunc(w, r, status)
|
||||
}
|
||||
} else {
|
||||
// Get the remote host
|
||||
remoteHost, _, err := net.SplitHostPort(r.RemoteAddr)
|
||||
if err != nil {
|
||||
remoteHost = r.RemoteAddr
|
||||
}
|
||||
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
fmt.Fprintf(w, "No such host at %s", s.Server.Addr)
|
||||
log.Printf("[INFO] %s - No such host at %s (requested by %s)", host, s.Server.Addr, remoteHost)
|
||||
|
|
Loading…
Add table
Reference in a new issue