Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WSO2: passing the caller's IP address to the backend

Say an instance of WSO2's API Manager receives API calls from an external client, it is possible to pass the caller's IP address to the backend (in the header for example, other solutions are welcome too)? If yes how?

like image 335
Jérôme Verstrynge Avatar asked Mar 12 '23 07:03

Jérôme Verstrynge


1 Answers

HTTP Header is the way to do it. You can create a sequence like this and attach to API.

<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="sample">
    <property name="client_ip" expression="get-property('axis2', 'REMOTE_ADDR')" scope="transport"/>
</sequence>

If you have a proxy before API Manager, you may not be able to identify the real client using REMOTE_ADDR. It will be the IP of the proxy. In such cases you can use X-Forwarded-For http header.

like image 181
Bee Avatar answered Mar 19 '23 16:03

Bee