default to serve host content instead of 404

This commit is contained in:
Mikaël Cluseau 2018-11-02 15:30:12 +11:00
parent 33bf54d08f
commit 7ef45a39f9
2 changed files with 3 additions and 7 deletions

View File

@ -54,8 +54,7 @@ func hostByIP(w http.ResponseWriter, r *http.Request) (*clustersconfig.Host, *cl
remoteAddr := r.RemoteAddr
if *trustXFF {
xff := r.Header.Get("X-Forwarded-For")
if xff != "" {
if xff := r.Header.Get("X-Forwarded-For"); xff != "" {
remoteAddr = strings.Split(xff, ",")[0]
}
}

View File

@ -33,11 +33,8 @@ func main() {
go casCleaner()
http.HandleFunc("/ipxe", serveHostByIP)
http.HandleFunc("/kernel", serveHostByIP)
http.HandleFunc("/initrd", serveHostByIP)
http.HandleFunc("/boot.iso", serveHostByIP)
http.HandleFunc("/static-pods", serveHostByIP)
// by default, serve a host resource by its IP
http.HandleFunc("/", serveHostByIP)
http.HandleFunc("/hosts", serveHosts)
http.HandleFunc("/hosts/", serveHost)