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()
|
||||
|
||||
fmt.Println(http.ListenAndServe(*bindAddr, &httputil.ReverseProxy{
|
||||
Director: func(r *http.Request) {
|
||||
if i, ok := routedHostnames[string(r.Host)]; ok {
|
||||
r.Header.Set("X-Hostsplitter-Secret", Sites[i].Secret)
|
||||
r.Header.Set("Host", r.Host)
|
||||
r.URL.Scheme = "http"
|
||||
r.URL.Host = Sites[i].GetBackend()
|
||||
r.RequestURI = ""
|
||||
HTTPLogger(r, http.StatusOK)
|
||||
} else {
|
||||
HTTPLogger(r, http.StatusBadRequest)
|
||||
}
|
||||
},
|
||||
}))
|
||||
r := new(revProx)
|
||||
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 {
|
||||
reverseProxy := new(httputil.ReverseProxy)
|
||||
reverseProxy.Director = func(r *http.Request) {
|
||||
r.Header.Set("X-Hostsplitter-Secret", Sites[i].Secret)
|
||||
r.Header.Set("Host", r.Host)
|
||||
r.URL.Scheme = "http"
|
||||
r.URL.Host = Sites[i].GetBackend()
|
||||
r.RequestURI = ""
|
||||
HTTPLogger(r, http.StatusOK)
|
||||
}
|
||||
reverseProxy.ServeHTTP(w, r)
|
||||
} else {
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user