Reseting the X-FORWARDED-FOR header variable for outbound request (Apigee to backend).

Not applicable

Hi all,

When I create an assign message policy in the api proxy endpoitn preflow and set the header like this:

<Set><Headers><Headername="x-forwarded-for">{client.ip}</Header></Headers></Set>

When I run the trace UI, I can see the request header variable x-forwarded-for is setting proper client IP.

However, when I receive the request from the apigee in my backend service and log the request header, I am getting apigee message processors IP address rather than the client IP as I set in the set in the header.

Why this is happening and how do I resolve it?

7663-screen-shot-2018-11-05-at-41202-pm.png

0 3 1,653
3 REPLIES 3

sidd-harth
Participant V

Hi @Fazle Tanjil, have a look at this post,

https://community.apigee.com/articles/30998/getting-actual-client-ips-in-the-x-forwarded-for-h.html

Please try below,

    <Set>
        <Headers>
            <Header name="x-forwarded-for">{request.header.x-forwarded-for}</Header>
        </Headers>
    </Set>

Thanks for the reply. I tried this one. Still the same. The funny thing is in the trace UI, the request header information shows that they are setting this value to request.header.x-forwarded-for with correct client IP.

7671-screen-shot-2018-11-06-at-94104-am.png

But in my backend service (just console.log(req.headers) shows me that the x-forwarded-for header variable is the Apigee Message processor's IP. Like below:

7672-screen-shot-2018-11-06-at-94138-am.png

The above is not the client ip.