Standardize using the HTTP_X_REAL_IP header
It seems that there are multiple places which try to obtain the real remote IP of the request, but the logic is in multiple places:
- ActionDispatch::Request#remote_ip
- Rack::Request#ip
The first doesn't handle requests coming directly from a load balancer properly, while the second does. Rails is standardizing across the first. We've had to work around the problem in https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/26055/diffs.
We ship NGINX with the real_ip module, and we should consider using this header if available. This would solve a number of issues:
- https://gitlab.com/gitlab-org/gitlab-ce/issues/58848
- https://gitlab.com/gitlab-org/gitlab-ce/issues/58573
Sentry does this: https://github.com/getsentry/raven-ruby/pull/546/files