# IP Lookup is Pulling CDN's X-Forwarded-For

**URL:** https://meta.discourse.org/t/ip-lookup-is-pulling-cdns-x-forwarded-for/202918
**Category:** Self-hosting
**Created:** [September 8, 2021, 1:13am UTC](https://meta.discourse.org/t/ip-lookup-is-pulling-cdns-x-forwarded-for/202918 "2021-09-08T01:13:42Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![Isambard](https://avatars.discourse-cdn.com/v4/letter/i/858c86/32.png) [@Isambard](https://meta.discourse.org/u/Isambard)
#### Post date: [June 21, 2024, 2:12pm UTC](https://meta.discourse.org/t/ip-lookup-is-pulling-cdns-x-forwarded-for/202918/5 "2024-06-21T14:12:58Z")

</div>

I just encounted this problem with Cloudflare when I turned on their proxy.

I fixed by changing the Nginx config. You ahve to find all the proxy IP addresses and for each one in the http section:

```plaintext
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
...

```

Then you can set the real IP from the header passed by Cloudflare:

`real_ip_header CF-Connecting-IP;`

Since the proxy IP addresses could change, I’ll need to automate pulling and updating these.

Then reload/restart nginx with:

`sv nginx reload` or `sv nginx restart`

Argh. I wish I’d seen this post earlier! I’d just spent an hour today re-creating something that was already there: [X-Forwarded-For proxy tag not recognized by Discourse?](https://meta.discourse.org/t/x-forwarded-for-proxy-tag-not-recognized-by-discourse/77961/4):

> [@X-Forwarded-For proxy tag not recognized by Discourse?](https://meta.discourse.org/t/x-forwarded-for-proxy-tag-not-recognized-by-discourse/77961/4):
>
> Take a look at the `templates/cloudflare.template.yml` file. Basically, you need to insert `set_real_ip_from` directives

---

_[View the full topic](https://meta.discourse.org/t/ip-lookup-is-pulling-cdns-x-forwarded-for/202918)._
