http: Fix logging of proxied requests
This commit is contained in:
parent
88a364a155
commit
549958270c
@ -78,13 +78,15 @@ func (this *Handler) ServeHTTP (res http.ResponseWriter, req *http.Request) {
|
|||||||
remoteAddrStr := req.RemoteAddr
|
remoteAddrStr := req.RemoteAddr
|
||||||
if addr := req.Header.Get("CF-Connecting-IP"); addr != "" {
|
if addr := req.Header.Get("CF-Connecting-IP"); addr != "" {
|
||||||
if this.TrustCFConnectingIP {
|
if this.TrustCFConnectingIP {
|
||||||
|
proxy := req.RemoteAddr
|
||||||
req.RemoteAddr = addr
|
req.RemoteAddr = addr
|
||||||
remoteAddrStr = fmt.Sprintf("%s --CF-> %s", addr, req.RemoteAddr)
|
remoteAddrStr = fmt.Sprintf("%s --CF-> %s", addr, proxy)
|
||||||
}
|
}
|
||||||
} else if addr := req.Header.Get("X-Forwarded-For"); addr != "" {
|
} else if addr := req.Header.Get("X-Forwarded-For"); addr != "" {
|
||||||
if this.TrustXForwardedFor {
|
if this.TrustXForwardedFor {
|
||||||
|
proxy := req.RemoteAddr
|
||||||
req.RemoteAddr = addr
|
req.RemoteAddr = addr
|
||||||
remoteAddrStr = fmt.Sprintf("%s --XF-> %s", addr, req.RemoteAddr)
|
remoteAddrStr = fmt.Sprintf("%s --XF-> %s", addr, proxy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Println("(i)", req.Method, req.URL, "from", remoteAddrStr)
|
log.Println("(i)", req.Method, req.URL, "from", remoteAddrStr)
|
||||||
|
Loading…
Reference in New Issue
Block a user