{"action":"created","issue":{"url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4944","repository_url":"https://api.github.com/repos/bcit-ci/CodeIgniter","labels_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4944/labels{/name}","comments_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4944/comments","events_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4944/events","html_url":"https://github.com/bcit-ci/CodeIgniter/issues/4944","id":195922689,"number":4944,"title":"ip_address() on AWS and Load Balancer","user":{"login":"gorankrgovic","id":12137730,"avatar_url":"https://avatars.githubusercontent.com/u/12137730?v=3","gravatar_id":"","url":"https://api.github.com/users/gorankrgovic","html_url":"https://github.com/gorankrgovic","followers_url":"https://api.github.com/users/gorankrgovic/followers","following_url":"https://api.github.com/users/gorankrgovic/following{/other_user}","gists_url":"https://api.github.com/users/gorankrgovic/gists{/gist_id}","starred_url":"https://api.github.com/users/gorankrgovic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gorankrgovic/subscriptions","organizations_url":"https://api.github.com/users/gorankrgovic/orgs","repos_url":"https://api.github.com/users/gorankrgovic/repos","events_url":"https://api.github.com/users/gorankrgovic/events{/privacy}","received_events_url":"https://api.github.com/users/gorankrgovic/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-15T21:37:21Z","updated_at":"2016-12-16T10:07:11Z","closed_at":"2016-12-16T10:07:11Z","body":"I don't know why and this is really a weird behavior, but when you want to fetch the user IP address with $this->input->ip_address() it gives you the VPC ip address instead of the user! Tried on multiple instances and it's always the same behavior. Tried with custom function like:\r\n\r\n```\r\npublic function get_client_ip() {\r\n        $ipaddress = '';\r\n        if (getenv('HTTP_CLIENT_IP'))\r\n            $ipaddress = getenv('HTTP_CLIENT_IP');\r\n        else if(getenv('HTTP_X_FORWARDED_FOR'))\r\n            $ipaddress = getenv('HTTP_X_FORWARDED_FOR');\r\n        else if(getenv('HTTP_X_FORWARDED'))\r\n            $ipaddress = getenv('HTTP_X_FORWARDED');\r\n        else if(getenv('HTTP_FORWARDED_FOR'))\r\n            $ipaddress = getenv('HTTP_FORWARDED_FOR');\r\n        else if(getenv('HTTP_FORWARDED'))\r\n            $ipaddress = getenv('HTTP_FORWARDED');\r\n        else if(getenv('REMOTE_ADDR'))\r\n            $ipaddress = getenv('REMOTE_ADDR');\r\n        else\r\n            $ipaddress = 'UNKNOWN';\r\n        return $ipaddress;\r\n    }\r\n```\r\n\r\nWhich gives me the correct ip address of the USER. \r\n\r\nOn ubuntu 16.04. PHP 7.0, latest codeigniter framework"},"comment":{"url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/comments/267559913","html_url":"https://github.com/bcit-ci/CodeIgniter/issues/4944#issuecomment-267559913","issue_url":"https://api.github.com/repos/bcit-ci/CodeIgniter/issues/4944","id":267559913,"user":{"login":"narfbg","id":1058011,"avatar_url":"https://avatars.githubusercontent.com/u/1058011?v=3","gravatar_id":"","url":"https://api.github.com/users/narfbg","html_url":"https://github.com/narfbg","followers_url":"https://api.github.com/users/narfbg/followers","following_url":"https://api.github.com/users/narfbg/following{/other_user}","gists_url":"https://api.github.com/users/narfbg/gists{/gist_id}","starred_url":"https://api.github.com/users/narfbg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narfbg/subscriptions","organizations_url":"https://api.github.com/users/narfbg/orgs","repos_url":"https://api.github.com/users/narfbg/repos","events_url":"https://api.github.com/users/narfbg/events{/privacy}","received_events_url":"https://api.github.com/users/narfbg/received_events","type":"User","site_admin":false},"created_at":"2016-12-16T10:07:11Z","updated_at":"2016-12-16T10:07:11Z","body":"@emilebourquin We have that feature built-in ...\r\n\r\n@gorankrgovic \r\n\r\nThe code you've shown allows *any* user to spoof their address. As I already said - we have a feature for your use case, you should use that to be safe.\r\n\r\nHowever, this is a bug tracker and we don't provide general support here.\r\nIf you need help with something, please post on our [forums](https://forum.codeigniter.com/) instead."}}
{"actor":{"display_login":"narfbg"}}