Apiman X-Fowarded-For on Simple Header Policy

193 views Asked by At

I'd like to know if there is some way to add the Client remote IP on my Request Header from API Man.

I need to add a Simple Header Policy with a "X-Forwarded-For" containing the client remote ip.

My backend is getting the APIMan IP as remote client, but what I need get to client IP.

1

There are 1 answers

0
ulab On

You can create a custom policy plugin and override doApply method to set the Client IP from ApiRequest object to the custom header like below.

 apiRequest.getHeaders().put("X-Forwarded-For", apiRequest.getRemoteAddr());

And add the new custom policy plugin to your services. This is a simple tutorial to create plugin