From e04e06d6e255f3f32b6cda5365b98dca94057363 Mon Sep 17 00:00:00 2001 From: Abiola Ibrahim Date: Tue, 28 Apr 2015 22:31:42 +0100 Subject: [PATCH] Fix for Issue 13: Trouble running in Docker containers (or binding to 0.0.0.0) --- server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/server.go b/server/server.go index 028278b0..40cf100d 100644 --- a/server/server.go +++ b/server/server.go @@ -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")