# Using haproxy how do I get Discourse to recognize remote IP?

**URL:** https://meta.discourse.org/t/using-haproxy-how-do-i-get-discourse-to-recognize-remote-ip/64647
**Category:** Self-hosting
**Created:** [2017年六月17日 00:10 UTC](https://meta.discourse.org/t/using-haproxy-how-do-i-get-discourse-to-recognize-remote-ip/64647 "2017-06-17T00:10:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Cyclops](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyclops/32/119674_2.png) [@Cyclops](https://meta.discourse.org/u/Cyclops)
#### Post date: [2017年六月17日 00:10 UTC](https://meta.discourse.org/t/using-haproxy-how-do-i-get-discourse-to-recognize-remote-ip/64647/1 "2017-06-17T00:10:40Z")

</div>

I’m using haproxy as a way of having apache, webmin, and pwm running on the same machine under different subdomains. The setup works beautifully, but Discourse shows the localhost for the IP address for all user activity, clearly this is going to make fighting spam harder (IP blocking would not work, etc).

Is there a way to get discourse to recognize the proper remote IP addresses?

---

<div class="post-metadata">

### Author: ![Cyclops](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cyclops/32/119674_2.png) [@Cyclops](https://meta.discourse.org/u/Cyclops)
#### Post date: [2017年六月17日 01:17 UTC](https://meta.discourse.org/t/using-haproxy-how-do-i-get-discourse-to-recognize-remote-ip/64647/2 "2017-06-17T01:17:06Z")

</div>

I solved this myself.

I had to add this to my haproxy.cfg under “defaults”:

```
option forwardfor

```

I feel kinda dumb, I had it in the wrong spot.

---

<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: [2017年六月19日 12:50 UTC](https://meta.discourse.org/t/using-haproxy-how-do-i-get-discourse-to-recognize-remote-ip/64647/3 "2017-06-19T12:50:18Z")

</div>


