{"action":"created","issue":{"url":"https://api.github.com/repos/deis/example-go/issues/11","labels_url":"https://api.github.com/repos/deis/example-go/issues/11/labels{/name}","comments_url":"https://api.github.com/repos/deis/example-go/issues/11/comments","events_url":"https://api.github.com/repos/deis/example-go/issues/11/events","html_url":"https://github.com/deis/example-go/pull/11","id":117194864,"number":11,"title":"fix(web.go): log X-Forwarded-For header","user":{"login":"krancour","id":1821014,"avatar_url":"https://avatars.githubusercontent.com/u/1821014?v=3","gravatar_id":"","url":"https://api.github.com/users/krancour","html_url":"https://github.com/krancour","followers_url":"https://api.github.com/users/krancour/followers","following_url":"https://api.github.com/users/krancour/following{/other_user}","gists_url":"https://api.github.com/users/krancour/gists{/gist_id}","starred_url":"https://api.github.com/users/krancour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krancour/subscriptions","organizations_url":"https://api.github.com/users/krancour/orgs","repos_url":"https://api.github.com/users/krancour/repos","events_url":"https://api.github.com/users/krancour/events{/privacy}","received_events_url":"https://api.github.com/users/krancour/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/deis/example-go/labels/awaiting%20review","name":"awaiting review","color":"e11d21"},{"url":"https://api.github.com/repos/deis/example-go/labels/LGTM1","name":"LGTM1","color":"009800"}],"state":"open","locked":false,"assignee":{"login":"krancour","id":1821014,"avatar_url":"https://avatars.githubusercontent.com/u/1821014?v=3","gravatar_id":"","url":"https://api.github.com/users/krancour","html_url":"https://github.com/krancour","followers_url":"https://api.github.com/users/krancour/followers","following_url":"https://api.github.com/users/krancour/following{/other_user}","gists_url":"https://api.github.com/users/krancour/gists{/gist_id}","starred_url":"https://api.github.com/users/krancour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krancour/subscriptions","organizations_url":"https://api.github.com/users/krancour/orgs","repos_url":"https://api.github.com/users/krancour/repos","events_url":"https://api.github.com/users/krancour/events{/privacy}","received_events_url":"https://api.github.com/users/krancour/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-11-16T19:02:27Z","updated_at":"2015-11-16T19:37:53Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/deis/example-go/pulls/11","html_url":"https://github.com/deis/example-go/pull/11","diff_url":"https://github.com/deis/example-go/pull/11.diff","patch_url":"https://github.com/deis/example-go/pull/11.patch"},"body":"This change makes the example-go application log the end user's IP instead of the IP of the last proxy.\r\n\r\nFor example, prior to this change, with Fleet as the scheduler, one would see this in the logs:\r\n\r\n```\r\n2015-11-16T18:47:18UTC vanity-pamphlet[web.1]: 2015/11/16 18:47:18 10.21.1.88:55672 GET /\r\n```\r\n\r\nThe IP there is the private IP of the host of whichever deis-router forwarded the request.\r\n\r\nWith k8s as the scheduler, one would have seen this:\r\n\r\n```\r\n2015-11-16T17:39:07UTC haptic-painting[web-cxjmk]: 2015/11/16 17:39:07 10.244.94.0:34783 GET /\r\n```\r\n\r\nThe IP there is the VIP of whatever kube-proxy forwarded the request.\r\n\r\nAfter this change, logs will always resemble the following:\r\n\r\n```\r\n2015-11-16T18:27:58UTC haptic-painting[web-j5ex1]: 2015/11/16 18:27:58 73.68.36.13 GET /\r\n```\r\n\r\nThe IP there is the IP of the end user.\r\n\r\nOther example apps may need similar attention.  I'm fixing this one in particular because it's the one I use most frequently, and as a means to an end, I need this accurately logging the end user's IP to aid in asserting that e2e HTTPS is working properly."},"comment":{"url":"https://api.github.com/repos/deis/example-go/issues/comments/157146399","html_url":"https://github.com/deis/example-go/pull/11#issuecomment-157146399","issue_url":"https://api.github.com/repos/deis/example-go/issues/11","id":157146399,"user":{"login":"bacongobbler","id":1360539,"avatar_url":"https://avatars.githubusercontent.com/u/1360539?v=3","gravatar_id":"","url":"https://api.github.com/users/bacongobbler","html_url":"https://github.com/bacongobbler","followers_url":"https://api.github.com/users/bacongobbler/followers","following_url":"https://api.github.com/users/bacongobbler/following{/other_user}","gists_url":"https://api.github.com/users/bacongobbler/gists{/gist_id}","starred_url":"https://api.github.com/users/bacongobbler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bacongobbler/subscriptions","organizations_url":"https://api.github.com/users/bacongobbler/orgs","repos_url":"https://api.github.com/users/bacongobbler/repos","events_url":"https://api.github.com/users/bacongobbler/events{/privacy}","received_events_url":"https://api.github.com/users/bacongobbler/received_events","type":"User","site_admin":false},"created_at":"2015-11-16T19:37:53Z","updated_at":"2015-11-16T19:37:53Z","body":"I think there would be use cases where we want to test the app across different hosts in a LAN. That way we could tell if the request came from localhost or another machine in the same network. Would you mind tuning it to that tune? Something like\r\n\r\n```\r\nremote := r.RemoteAddr\r\nif forwardedFor := r.Header.Get(\"X-Forwarded-For\"); forwardedFor != \"\" {\r\n    remote := forwardedFor\r\n}\r\n\r\nlog.Printf(...)\r\n```"}}