Don't route request that we shouldn't!
Oh man, I really hope that's fixed now... What a nightmare.
This commit is contained in:
parent
59e7ae16d4
commit
deda2ebfb9
@ -53,20 +53,29 @@ func main() {
|
|||||||
|
|
||||||
go SignalHandler()
|
go SignalHandler()
|
||||||
|
|
||||||
fmt.Println(http.ListenAndServe(*bindAddr, &httputil.ReverseProxy{
|
r := new(revProx)
|
||||||
Director: func(r *http.Request) {
|
fmt.Println(http.ListenAndServe(*bindAddr, r))
|
||||||
|
}
|
||||||
|
|
||||||
|
type revProx struct{}
|
||||||
|
|
||||||
|
func (p *revProx) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
if i, ok := routedHostnames[string(r.Host)]; ok {
|
if i, ok := routedHostnames[string(r.Host)]; ok {
|
||||||
|
reverseProxy := new(httputil.ReverseProxy)
|
||||||
|
reverseProxy.Director = func(r *http.Request) {
|
||||||
r.Header.Set("X-Hostsplitter-Secret", Sites[i].Secret)
|
r.Header.Set("X-Hostsplitter-Secret", Sites[i].Secret)
|
||||||
r.Header.Set("Host", r.Host)
|
r.Header.Set("Host", r.Host)
|
||||||
r.URL.Scheme = "http"
|
r.URL.Scheme = "http"
|
||||||
r.URL.Host = Sites[i].GetBackend()
|
r.URL.Host = Sites[i].GetBackend()
|
||||||
r.RequestURI = ""
|
r.RequestURI = ""
|
||||||
HTTPLogger(r, http.StatusOK)
|
HTTPLogger(r, http.StatusOK)
|
||||||
|
}
|
||||||
|
reverseProxy.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
||||||
HTTPLogger(r, http.StatusBadRequest)
|
HTTPLogger(r, http.StatusBadRequest)
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
w.Write([]byte("Bad Request"))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const apacheFormatPattern = "%s - - [%s] \"%s %s %s\" %d %d \"%s\" \"%s\" %.4f\n"
|
const apacheFormatPattern = "%s - - [%s] \"%s %s %s\" %d %d \"%s\" \"%s\" %.4f\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user