# Log $http\_x\_forwarded\_for behind Cisco ACE LB

**URL:** <https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470>\
**Category:** NGINX\
**Created:** [March 2, 2012, 11:58am UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470 "2012-03-02T11:58:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [March 2, 2012, 11:58am UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/1 "2012-03-02T11:58:58Z")

</div>

Hello !

I’m new to Nginx.

I installed Nginx (on Gentoo) instead of Apache behind a Cisco  
LoadBalancer.

My problem is that the directive $http\_x\_forwarded\_for always write  
local IP of the LoadBalancer instead of Real IP.

But I have the good IP in the header HTTP\_X\_FORWARD.

I’ve tried lot of configurations but no one is good…

Do you have any idea ?

Thanks by advance,

Tib1

Posted at Nginx Forum:

> **[Log $http\_x\_forwarded\_for behind Cisco ACE LB](https://forum.nginx.org/read.php?2,223259,223259#msg-223259)**
>
> Hello ! I'm new to Nginx. I installed Nginx (on Gentoo) instead of Apache behind a Cisco LoadBalancer. My problem is that the directive $http\_x\_forwarded\_for always write local IP of the LoadBalancer instead of Real IP. But I have the good

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 2, 2012, 12:01pm UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/2 "2012-03-02T12:01:27Z")

</div>

2012/3/2 Tib1 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> But I have the good IP in the header HTTP\_X\_FORWARD.

perhaps something like this:

set\_real\_ip\_from load\_balancer\_ip;  
real\_ip\_header X-Forwarded-For;

ref: [Module ngx\_http\_realip\_module](http://nginx.org/en/docs/http/ngx_http_realip_module.html)

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 2, 2012, 12:07pm UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/3 "2012-03-02T12:07:37Z")

</div>

Nope, I’ve tried this but without success…

Posted at Nginx Forum:

> **[Re: Log $http\_x\_forwarded\_for behind Cisco ACE LB](https://forum.nginx.org/read.php?2,223259,223261#msg-223261)**
>
> Hello ! I'm new to Nginx. I installed Nginx (on Gentoo) instead of Apache behind a Cisco LoadBalancer. My problem is that the directive $http\_x\_forwarded\_for always write local IP of the LoadBalancer instead of Real IP. But I have the good

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 2, 2012, 5:27pm UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/4 "2012-03-02T17:27:29Z")

</div>

How can I get the full request header ?

Posted at Nginx Forum:

> **[Re: Log $http\_x\_forwarded\_for behind Cisco ACE LB](https://forum.nginx.org/read.php?2,223259,223280#msg-223280)**
>
> Hello ! I'm new to Nginx. I installed Nginx (on Gentoo) instead of Apache behind a Cisco LoadBalancer. My problem is that the directive $http\_x\_forwarded\_for always write local IP of the LoadBalancer instead of Real IP. But I have the good

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 2, 2012, 5:46pm UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/5 "2012-03-02T17:46:20Z")

</div>

Problem solved.  
It’s the name of real\_ip\_header that was wrong in my CISCO system.

Thanks.

Posted at Nginx Forum:

> **[Re: Log $http\_x\_forwarded\_for behind Cisco ACE LB](https://forum.nginx.org/read.php?2,223259,223283#msg-223283)**
>
> Hello ! I'm new to Nginx. I installed Nginx (on Gentoo) instead of Apache behind a Cisco LoadBalancer. My problem is that the directive $http\_x\_forwarded\_for always write local IP of the LoadBalancer instead of Real IP. But I have the good

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 2, 2012, 12:09pm UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/6 "2012-03-02T12:09:30Z")

</div>

2012/3/2 Tib1 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Nope, I’ve tried this but without success…

I suggest posting the full request header sent by load balancer.

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 3, 2012, 6:59am UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/7 "2012-03-03T06:59:04Z")

</div>

02 марта 2012, 15:01 от Edho A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > But I have the good IP in the header HTTP\_X\_FORWARD.
> 
> perhaps something like this:
> 
> set\_real\_ip\_from load\_balancer\_ip;  
> real\_ip\_header X-Forwarded-For;

Replace X-Forwarded-For with X-Forward and that shouldl work.

You may want to update your Cisco ACE loadbalancing policy  
map configuration to insert the standard X-Forwarded-For  
instead of the X-Forward header by doing something like this  
in Exec mode:

host1/Admin# show running-config policy-map

You should see something like this:

policy-map type loadbalance http first-match L7\_LB\_POLICY  
class L7\_LB\_CLASS  
serverfarm SERVER\_FARM\_1  
insert-http x-forward header-value “%is”

Then just replace the header:

Host1/Admin# configure terminal  
Host1/Admin(config)# policy-map type loadbalance first-match  
L7\_LB\_POLICY  
host1/Admin(config-pmap-lb)# class L7\_LB\_CLASS  
host1/Admin(config-pmap-lb-c)# no insert-http X-Forward header-value  
“%is”  
host1/Admin(config-pmap-lb-c)# insert-http X-Forwarded-For header-value  
“%is”  
host1/Admin(config-pmap-lb-c)# exit  
host1/Admin(config)# exit

If everything works as expected just save your configuration and that’s  
it:  
host1/Admin# copy running-config startup-config

Max

---

<div class="post-metadata">

**Author:** ![Tib1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/fbc32d/32.png) [@Tib1](https://www.ruby-forum.com/u/Tib1)\
**Post date:** [March 3, 2012, 10:52am UTC](https://www.ruby-forum.com/t/log-http-x-forwarded-for-behind-cisco-ace-lb/217470/8 "2012-03-03T10:52:25Z")

</div>

Thank you very much Max !

In fact, it was the name of the header that was wrong.

And I didn’t make the connection between the value in the Cisco ACE and  
the value of the Nginx real\_ip\_header. I thought it was a constant.

So thank you again 🙂

Have a good day !

Posted at Nginx Forum:

> **[Re: Re\[2\]: Log $http\_x\_forwarded\_for behind Cisco ACE LB](https://forum.nginx.org/read.php?2,223273,223284#msg-223284)**
>
> 02 марта 2012, 15:01 от Edho Arief \<edho@myconan.net\>: \> 2012/3/2 Tib1 \<nginx-forum@nginx.us\>: \> \> Hello ! \> \> \> \> I'm new to Nginx. \> \> \> \> I installed Nginx (on Gentoo) instead of Apache behind a Cisco...
