Преглед на файлове

overwrite X-Forwarded-For header with True-Client-IP for Cloudflare

Tobias Begalke преди 7 години
родител
ревизия
174f4d4286
променени са 1 файла, в които са добавени 4 реда и са изтрити 0 реда
  1. 4 0
      main.go

+ 4 - 0
main.go

@@ -474,6 +474,10 @@ func processHTTP(request *data.Request, appData []byte) error {
 	if _, ok := req.Header["X-Forwarded-For"]; ok {
 		request.XForwardedFor = req.Header["X-Forwarded-For"][0]
 	}
+	// CloudFlare: override X-Forwarded for since it is tainted by cloudflare
+	if _, ok := req.Header["True-Client-IP"]; ok {
+		request.XForwardedFor = req.Header["True-Client-IP"][0]
+	}
 	if _, ok := req.Header["X-Real-IP"]; ok {
 		request.XRealIP = req.Header["X-Real-IP"][0]
 	}