# 使用 Cloudflare 时获取真实用户 IP

**URL:** https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707
**Category:** Support
**Created:** [2019年六月18日 17:10 UTC](https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707 "2019-06-18T17:10:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![BryanV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryanv/32/226479_2.png) [@BryanV](https://meta.discourse.org/u/BryanV)
#### Post date: [2019年六月18日 17:10 UTC](https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707/1 "2019-06-18T17:10:56Z")

</div>

I had a legitimate user message me directly saying that they could not sign up up because “New registrations are not allowed from your IP address”

After some investigation I found the relevant setting and bumped it up to 9999. But then I wanted to investigate further, so looked up the users reg IP after they signed up:

 ![41%20AM](https://global.discourse-cdn.com/meta/original/3X/f/5/f57c1509dd08167731f1f117acf674079d2c7ee8.png)

The other threads about this setting seem to indicate that repeat reg IPs should not be common, that the low default of 3 is reasonable. So does this situation with multiple reg ids coming from Cloudflare point to some misconfiguration I need to look in to? This instance is running on Digital Ocean, and there is just an A record on CloudFlare pointing at it.

As an aside I would strongly suggest admins be notified when users are turned away for this reason. I would never have known about or been able to help them sign up except that they emailied me directly.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [2019年六月18日 17:13 UTC](https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707/2 "2019-06-18T17:13:40Z")

</div>

Cloudflare acts as a proxy between your users and your server, which means the default configuration will show Cloudflare nodes rather than origin IPs.

You need to add the Cloudflare template to your app.yml so that you can see the true originating IP of your users.

Under `templates:` add:

` - "templates/cloudflare.template.yml"`

Then rebuild.

---

<div class="post-metadata">

### Author: ![BryanV](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bryanv/32/226479_2.png) [@BryanV](https://meta.discourse.org/u/BryanV)
#### Post date: [2019年六月18日 18:13 UTC](https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707/3 "2019-06-18T18:13:48Z")

</div>

Brilliant, thank you!

---

<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: [2019年七月18日 18:14 UTC](https://meta.discourse.org/t/true-user-ips-when-using-cloudflare/120707/4 "2019-07-18T18:14:02Z")

</div>

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