# Last IP address and action\_dispatch.trusted\_proxies

**URL:** <https://meta.discourse.org/t/last-ip-address-and-action-dispatch-trusted-proxies/50098>\
**Category:** Product Support\
**Created:** [13 سبتمبر 2016، 5:50م UTC](https://meta.discourse.org/t/last-ip-address-and-action-dispatch-trusted-proxies/50098 "2016-09-13T17:50:59Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![dorian\_kind](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dorian_kind/32/115240_2.png) [@dorian\_kind](https://meta.discourse.org/u/dorian_kind)\
**Post date:** [14 سبتمبر 2016، 3:52م UTC](https://meta.discourse.org/t/last-ip-address-and-action-dispatch-trusted-proxies/50098/4 "2016-09-14T15:52:07Z")

</div>

Thanks for your feedback! I’m not sure if this specific workaround would help in our case, as all IPs involved are in `10.0.0.0/16` and would still be in `RemoteIp`’s `TRUSTED_PROXIES` list.

Here’s the [relevant code](https://github.com/rails/rails/blob/4-2-stable/actionpack/lib/action_dispatch/middleware/remote_ip.rb#L130) from Rails 4.2. Interestingly, `X-Real-IP` doesn’t appear anywhere there, only `X-Forwarded-For` and `Client-Ip`:

> ```
> # We assume these things about the IP headers:
> #
> # - X-Forwarded-For will be a list of IPs, one per proxy, or blank
> # - Client-Ip is propagated from the outermost proxy, or is blank
> # - REMOTE_ADDR will be the IP that made the request to Rack
> ips = [forwarded_ips, client_ips, remote_addr].flatten.compact
> 
> ```

> ```
> # If every single IP option is in the trusted list, just return REMOTE_ADDR
> filter_proxies(ips).first || remote_addr
> 
> ```

If I understand it correctly, `filter_proxies` removes all IP address from `ips` that are in `TRUSTED_PROXIES `, no matter whether they originally came from `X-Forwarded-For` or `Client-Ip`. So we would still end up with `remote_addr`, which will always be `127.0.0.1`

I do realize that this probably more of a Rack/Rails topic than a Discourse one. But maybe someone else has a similar setup and managed to have the proper last IP addresses displayed in the admin interface.

---

_[View the full topic](https://meta.discourse.org/t/last-ip-address-and-action-dispatch-trusted-proxies/50098)._
