Handle multiple X-Forwarded-For addresses in runner IP
As raised in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24624#note_144220505, the X-Forwarded-For header may contain multiple IPs. Each chain in the proxy will add its own IP.
The naive solution would be just to pick the first IP, but https://github.com/rack/rack/issues/1049#issuecomment-210556173 has an argument that you can't always trust the IPs in the list.
In Rails, this is the algorithm:
We couldn't use request.remote_ip because we're coming from Grape, but perhaps we can adapt this method (or contribute it to Grape).
Edited by Stan Hu