log X-Forwarded-For as ClientHost if present
This commit is contained in:
parent
086a85d2f0
commit
92fb86b66f
1 changed files with 4 additions and 0 deletions
|
@ -127,6 +127,10 @@ func (l *LogHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request, next h
|
|||
core[ClientHost], core[ClientPort] = silentSplitHostPort(req.RemoteAddr)
|
||||
core[ClientUsername] = usernameIfPresent(req.URL)
|
||||
|
||||
if forwardedFor := req.Header.Get("X-Forwarded-For"); forwardedFor != "" {
|
||||
core[ClientHost] = forwardedFor
|
||||
}
|
||||
|
||||
crw := &captureResponseWriter{rw: rw}
|
||||
|
||||
next.ServeHTTP(crw, reqWithDataTable)
|
||||
|
|
Loading…
Reference in a new issue