# Send sourceIP to backend

**URL:** <https://discourse.haproxy.org/t/send-sourceip-to-backend/6454>\
**Category:** Help!\
**Created:** [April 9, 2021, 4:50am UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454 "2021-04-09T04:50:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rend](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@Rend](https://discourse.haproxy.org/u/Rend)\
**Post date:** [April 9, 2021, 4:50am UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454/1 "2021-04-09T04:50:45Z")

</div>

Hello!  
We are looking for a solution helping us distribute(balance) incoming traffic to server farm. We are interested in to use HAPROXY as load balancer. Provided some experiments we had realized we weren’t able to transmit sourceIP (clientIP) to the back-end. It is because of the back-ends placed in local area network ip space and clients connects from the Internet.\*\*

Scheme is:

clientIP – (Internet)–\>[HA frontendIP | HA backendIP] --(LAN)–\> backends

If we cannot send clientIP to backend we cannot use HAPROXY as balancer. But we want:)

Backend supports special protocol allowing receive clientIP. Is there ability integrate it to HAPROXY? May there another way solve out issue?

---

<div class="post-metadata">

**Author:** ![baptiste64](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@baptiste64](https://discourse.haproxy.org/u/baptiste64)\
**Post date:** [April 9, 2021, 4:03pm UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454/2 "2021-04-09T16:03:36Z")

</div>

Hi,

You just have to configure HAProxy to use the proxy protocol to send the client IP.  
[https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#5.2-send-proxy](https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#5.2-send-proxy)

---

<div class="post-metadata">

**Author:** ![Rend](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@Rend](https://discourse.haproxy.org/u/Rend)\
**Post date:** [April 13, 2021, 6:08am UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454/3 "2021-04-13T06:08:29Z")

</div>

Thanks for help  
Let me know. This solution uses Proxy Protocol ([Proxy Protocol - HAProxy Technologies](https://www.haproxy.com/blog/haproxy/proxy-protocol/)) and I have to add support it in my software working at backends. Am I right?

---

<div class="post-metadata">

**Author:** ![baptiste64](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@baptiste64](https://discourse.haproxy.org/u/baptiste64)\
**Post date:** [April 13, 2021, 5:30pm UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454/4 "2021-04-13T17:30:25Z")

</div>

Yes, the proxy protocol (v1 or v2) must be activated at both ends: on your haproxy backend configuration, and on the target server configuration.

---

<div class="post-metadata">

**Author:** ![Goodmirek](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/goodmirek/32/1325_2.png) [@Goodmirek](https://discourse.haproxy.org/u/Goodmirek)\
**Post date:** [April 14, 2021, 12:30pm UTC](https://discourse.haproxy.org/t/send-sourceip-to-backend/6454/5 "2021-04-14T12:30:17Z")

</div>

The solution could be either proxy protocol, as already mentioned, if traffic is loadbalanced on layer 4 (TCP). Indeed the proxy protocol of the same version must be activated in both HAProxy backend config and in the server farm.

Or the solution could be X-forwarded-for header, if traffic is loadbalanced on layer 7 (HTTP). This option is typically easier to use. Look at HAProxy configuration directive `option forwardfor`, see [here](https://cbonte.github.io/haproxy-dconv/2.3/configuration.html#4-option%20forwardfor).
