# Discourse reports user ips as the load balancer

**URL:** https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049
**Category:** Development
**Created:** [May 31, 2016, 5:51pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049 "2016-05-31T17:51:17Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![nhumrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nhumrich/32/121751_2.png) [@nhumrich](https://meta.discourse.org/u/nhumrich)
#### Post date: [May 31, 2016, 5:51pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/1 "2016-05-31T17:51:17Z")

</div>

I have an external load balancer (aws ELB) directing traffic to my discourse server. I have verified the `X-Forwarded-For` headers are being sent, but for some reason all the user ips show up as the load balancer ip?

Is this a bug or is there some setting I am missing?

---

<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: [May 31, 2016, 6:16pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/2 "2016-05-31T18:16:01Z")

</div>

I know @mpalmer knows a lot about this. Any advice, Matt?

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [May 31, 2016, 10:54pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/3 "2016-05-31T22:54:47Z")

</div>

I’d say you’re missing the nginx setting to “trust” the IP address that is making the connection, so the XFF header is ignored. The setting name is `set_real_ip_from`; grovel around in your nginx config(s) to see what (if anything) it’s currently set to, and season to taste.

---

<div class="post-metadata">

### Author: ![nhumrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nhumrich/32/121751_2.png) [@nhumrich](https://meta.discourse.org/u/nhumrich)
#### Post date: [June 1, 2016, 4:37pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/4 "2016-06-01T16:37:25Z")

</div>

Thanks, found the solution here: [Amazon Elastic Load Balancer and Forwarding Real-IP Nginx](https://easyengine.io/tutorials/nginx/amazon-elastic-load-balancer-forward-real-ip/)

basically, add the following to the http section in nginx.conf

```
real_ip_header X-Forwarded-For;
set_real_ip_from 0.0.0.0/0;

```

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [June 1, 2016, 10:49pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/5 "2016-06-01T22:49:47Z")

</div>

> [@nhumrich](#):
>
> set\_real\_ip\_from 0.0.0.0/0;

Oh sweet jeebers, don’t do that. It’ll allow anyone who can manage to get a HTTP connection into your servers to spoof their IP address, which will only lead to trouble. Set it to the IP range of your VPC, instead.

---

<div class="post-metadata">

### Author: ![nhumrich](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nhumrich/32/121751_2.png) [@nhumrich](https://meta.discourse.org/u/nhumrich)
#### Post date: [June 1, 2016, 11:33pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/6 "2016-06-01T23:33:18Z")

</div>

oh ya, I know that much, I just didnt want to post my range to the public 😉

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [June 1, 2016, 11:54pm UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/7 "2016-06-01T23:54:57Z")

</div>

Sure, but will everyone _else_ who finds this topic and copies your example know that?

---

<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: [June 2, 2016, 12:12am UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/8 "2016-06-02T00:12:18Z")

</div>

Well, they’ll surely scroll down and see your reply just under it, though? I suspect yes.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [June 2, 2016, 12:13am UTC](https://meta.discourse.org/t/discourse-reports-user-ips-as-the-load-balancer/45049/9 "2016-06-02T00:13:13Z")

</div>

That’s why I made my reply.
