Fix for Issue 13: Trouble running in Docker containers (or binding to 0.0.0.0)

This commit is contained in:
Abiola Ibrahim 2015-04-28 22:31:42 +01:00
parent 17fa5a9334
commit e04e06d6e2

View file

@ -161,6 +161,13 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
host = r.Host // oh well
}
// Try the host as given, or try falling back to 0.0.0.0 (wildcard)
if _, ok := s.vhosts[host]; !ok {
if _, ok2 := s.vhosts["0.0.0.0"]; ok2 {
host = "0.0.0.0"
}
}
if vh, ok := s.vhosts[host]; ok {
w.Header().Set("Server", "Caddy")