# 我的安装中 IP 地址不正确

**URL:** <https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366>\
**Category:** Support\
**Created:** [2018年十二月31日 12:10 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366 "2018-12-31T12:10:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sau226](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sau226/32/302324_2.png) [@sau226](https://meta.discourse.org/u/sau226)\
**Post date:** [2018年十二月31日 12:10 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/1 "2018-12-31T12:10:17Z")

</div>

Currently the Discourse IP lookup feature is broken (assuming a Docker install using the [official install guide](https://github.com/discourse/discourse/blob/master/docs/INSTALL-cloud.md)).

**Repro steps:**

1. Install a fresh Discourse instance (Ubuntu server in VM, only accessible from local network)
2. Create at least 3 accounts (developer/admin, moderator and normal user) using different physical devices (e.g. phone, desktop)
3. Open a random account and click IP lookup next to any of the IP addresses listed.

**Expected behavior:** User should be listed along with all users created from that device.  
**Current behavior:** User is displayed along with all accounts created on instance.

**Screenshot:**

 ![screenshot](https://global.discourse-cdn.com/meta/original/3X/f/a/fabba2366fd0edae04cef1a711cce172a1249b61.png)

---

<div class="post-metadata">

**Author:** ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)\
**Post date:** [2018年十二月31日 12:47 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/2 "2018-12-31T12:47:27Z")

</div>

Your IPs are not logging properly to begin with. So this feels like a setup issue, are you behind cloudflare? Or any sort of proxy?

---

<div class="post-metadata">

**Author:** ![sau226](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sau226/32/302324_2.png) [@sau226](https://meta.discourse.org/u/sau226)\
**Post date:** [2019年一月1日 02:22 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/3 "2019-01-01T02:22:11Z")

</div>

It is not behind any sort of proxy. This server happens to be running in my internal network (192.168.1.xx) via [nip.io](http://nip.io) and I can confirm that the server is receiving XFF headers with my IP in them per the rails environment presented by the developer-only mini profiler (screenshot below).

 ![screenshot](https://global.discourse-cdn.com/meta/original/3X/9/9/99e42e0f881da13fec6b7aa2c68dcb87f6197034.png)

---

<div class="post-metadata">

**Author:** ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)\
**Post date:** [2019年一月1日 03:28 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/4 "2019-01-01T03:28:32Z")

</div>

Maybe your internal corp network is using NAT so many users appear to come from the same IP address?

---

<div class="post-metadata">

**Author:** ![michaeld](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michaeld/32/1594_2.png) [@michaeld](https://meta.discourse.org/u/michaeld)\
**Post date:** [2019年一月1日 05:10 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/5 "2019-01-01T05:10:55Z")

</div>

Edit: apparently, the mini profiler shows it that way

You’re testing with local addresses and those are handled in a special way by the RoR middleware.

---

<div class="post-metadata">

**Author:** ![sau226](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sau226/32/302324_2.png) [@sau226](https://meta.discourse.org/u/sau226)\
**Post date:** [2019年一月1日 05:47 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/6 "2019-01-01T05:47:53Z")

</div>

I’m very, very sure that there is no proxy configuration on any of my devices whatsoever. The only things I could envision being a proxy are at the virtualbox layer (the server recognizes my real IP in last connected when I ssh to it though) or at router level (it may be set for NAT).

How might I tell Discourse to trust/use the XFF header set by whatever is saying localhost or do I have to open a new topic for that?

---

<div class="post-metadata">

**Author:** ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)\
**Post date:** [2019年一月2日 02:33 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/7 "2019-01-02T02:33:51Z")

</div>

`192.168.1.134` is a private IP, you are basically saying you want REMOTE ADDR to be some arbitrary private IP address here.

Rack does not like it when you forward for private IP addresses per:

> <https://github.com/rack/rack/blob/main/lib/rack/request.rb#L20>

So if you want special treatment there and to allow multiple users in a LAN all to be treated as if they have different private IPs there is some rack patching needed which you would need to do in a plugin.

You basically need to set `Rack::Request.ip_filter = lambda { |ip| false }` in a very simple plugin.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2021年十二月3日 15:38 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/8 "2021-12-03T15:38:48Z")

</div>



---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [2022年一月2日 15:39 UTC](https://meta.discourse.org/t/ip-addresses-are-not-correct-in-my-installation/105366/9 "2022-01-02T15:39:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
