git » gofer » commit ac5fd96

http: Log the requested host

author Alberto Bertogli
2017-08-11 23:29:36 UTC
committer Alberto Bertogli
2017-08-11 23:46:14 UTC
parent 1b9fa1688d470b9d0d644fdff71e001f1c73748d

http: Log the requested host

Today, we only see the resulting URL but not the requested host, which
can be important on a server with virtual domains.

So this patch adds the requested host to the HTTP logs, changing the
format a bit to make it (hopefully) more readable.

proxy/http.go +3 -1

diff --git a/proxy/http.go b/proxy/http.go
index 4dddd73..fa6ee88 100644
--- a/proxy/http.go
+++ b/proxy/http.go
@@ -123,7 +123,9 @@ func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error)
 		resps = fmt.Sprintf("%d", response.StatusCode)
 	}
 
-	util.Log.Printf("%s %s %s -> %s%s", req.RemoteAddr, req.Proto, req.URL,
+	// 1.2.3.4:34575 HTTP/2.0 domain.com https://backend/path -> 200
+	util.Log.Printf("%s %s %s %s -> %s%s",
+		req.RemoteAddr, req.Proto, req.Host, req.URL,
 		resps, errs)
 
 	return response, err