{"action":"created","issue":{"url":"https://api.github.com/repos/labstack/echo/issues/512","repository_url":"https://api.github.com/repos/labstack/echo","labels_url":"https://api.github.com/repos/labstack/echo/issues/512/labels{/name}","comments_url":"https://api.github.com/repos/labstack/echo/issues/512/comments","events_url":"https://api.github.com/repos/labstack/echo/issues/512/events","html_url":"https://github.com/labstack/echo/issues/512","id":155266356,"number":512,"title":"logger: invalid remote ip","user":{"login":"woniu369","id":9634079,"avatar_url":"https://avatars.githubusercontent.com/u/9634079?v=3","gravatar_id":"","url":"https://api.github.com/users/woniu369","html_url":"https://github.com/woniu369","followers_url":"https://api.github.com/users/woniu369/followers","following_url":"https://api.github.com/users/woniu369/following{/other_user}","gists_url":"https://api.github.com/users/woniu369/gists{/gist_id}","starred_url":"https://api.github.com/users/woniu369/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woniu369/subscriptions","organizations_url":"https://api.github.com/users/woniu369/orgs","repos_url":"https://api.github.com/users/woniu369/repos","events_url":"https://api.github.com/users/woniu369/events{/privacy}","received_events_url":"https://api.github.com/users/woniu369/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-17T13:57:40Z","updated_at":"2016-05-18T11:32:14Z","closed_at":null,"body":"```\r\ncurl -H 'X-Forwarded-For: \"invalid_ip' http://127.0.0.1\r\n```\r\noutput:\r\n```js\r\n{\"time\":\"2016-05-17T21:34:51+08:00\",\"remote_ip\":\"\"invalid_ip\",\"method\":\"GET\",\"uri\":\"/\",\"status\":200, \"latency\":30810,\"latency_human\":\"780.105µs\",\"rx_bytes\":0,\"tx_bytes\":41}\r\n```\r\n\r\nhttps://github.com/labstack/echo/blob/master/middleware/logger.go#L111-L119\r\nmodify:\r\n```go\r\nvar ra string\r\nif ip := req.Header().Get(echo.HeaderXRealIP); ip != \"\" {\r\n\tra = ip\r\n} else if ip = req.Header().Get(echo.HeaderXForwardedFor); ip != \"\" {\r\n\tra = ip\r\n}\r\nif net.ParseIP(ra) == nil {\r\n\tra, _, _ = net.SplitHostPort(req.RemoteAddress())\r\n}\r\nreturn w.Write([]byte(ra))\r\n```\r\noutput:\r\n```js\r\n{\"time\":\"2016-05-17T21:34:51+08:00\",\"remote_ip\":\"127.0.0.1\",\"method\":\"GET\",\"uri\":\"/\",\"status\":200, \"latency\":30810,\"latency_human\":\"780.105µs\",\"rx_bytes\":0,\"tx_bytes\":41}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/labstack/echo/issues/comments/219999638","html_url":"https://github.com/labstack/echo/issues/512#issuecomment-219999638","issue_url":"https://api.github.com/repos/labstack/echo/issues/512","id":219999638,"user":{"login":"johndeng","id":2155510,"avatar_url":"https://avatars.githubusercontent.com/u/2155510?v=3","gravatar_id":"","url":"https://api.github.com/users/johndeng","html_url":"https://github.com/johndeng","followers_url":"https://api.github.com/users/johndeng/followers","following_url":"https://api.github.com/users/johndeng/following{/other_user}","gists_url":"https://api.github.com/users/johndeng/gists{/gist_id}","starred_url":"https://api.github.com/users/johndeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johndeng/subscriptions","organizations_url":"https://api.github.com/users/johndeng/orgs","repos_url":"https://api.github.com/users/johndeng/repos","events_url":"https://api.github.com/users/johndeng/events{/privacy}","received_events_url":"https://api.github.com/users/johndeng/received_events","type":"User","site_admin":false},"created_at":"2016-05-18T11:32:14Z","updated_at":"2016-05-18T11:32:14Z","body":"Did you using a Nginx proxy or another proxy?"}}