|
@@ -278,6 +278,18 @@ func nginxLogCapture(logfile, format string) {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
+ if *useXForwardedAsSource {
|
|
|
+ xff, err := logEntry.Field("http_x_forwarded_for")
|
|
|
+ if err != nil {
|
|
|
+ remote = xff
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if remote == "" {
|
|
|
+ log.Println("remote is empty: ignoring request.")
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
// only use the first host in case there are multiple hosts in the log
|
|
|
if cidx := strings.Index(remote, ","); cidx >= 0 {
|
|
|
remote = remote[0:cidx]
|