# HAProxy rate limiting (X-Forwarder-For header)

**URL:** <https://discourse.haproxy.org/t/haproxy-rate-limiting-x-forwarder-for-header/8210>\
**Category:** Help!\
**Created:** [December 12, 2022, 10:08am UTC](https://discourse.haproxy.org/t/haproxy-rate-limiting-x-forwarder-for-header/8210 "2022-12-12T10:08:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![abu](https://avatars.discourse-cdn.com/v4/letter/a/f19dbf/32.png) [@abu](https://discourse.haproxy.org/u/abu)\
**Post date:** [December 12, 2022, 10:08am UTC](https://discourse.haproxy.org/t/haproxy-rate-limiting-x-forwarder-for-header/8210/1 "2022-12-12T10:08:36Z")

</div>

Hi!

We have mobile clients behind loadbalancer that all use the same IP address. The real IP address of the client is defined in client’s X-Forwarder-For header. We want to capture X-Forwarder-For header and apply rate limiting for unique IP address and API path (POST method). Are there any examples of this?

---

<div class="post-metadata">

**Author:** ![Toami](https://avatars.discourse-cdn.com/v4/letter/t/51bf81/32.png) [@Toami](https://discourse.haproxy.org/u/Toami)\
**Post date:** [December 21, 2022, 4:59am UTC](https://discourse.haproxy.org/t/haproxy-rate-limiting-x-forwarder-for-header/8210/2 "2022-12-21T04:59:56Z")

</div>

Hi,  
I think the src IP is not set correctly in your Haproxy.  
Try this line in your Haproxy and then check your Ha logs to make sure that src IP is unique per client.

> http-request set-src hdr(x-forwarded-for)

In case of unique IPs, you can define a stick-table to limit rates per IP.
