I'm trying to add "client_ip" in to a response header, but I can see the IP address is being printed on the kong apigateway logs but cannot forward it to a response header,
Sample log output:
,"method":"GET"},"client_ip":"49.36.22.209","tries":[{"balancer
I was trying following methods to try it out, but still response header is not printed the ip address.
- name: response-transformer
route: routeName
config:
add:
headers:
- X-Real-IP:${{client_ip}}
Can anyone help me to try enable this header on kong apigateway configs ?
Thanks.
You could use the plugin "serverless-functions"
In your case you would use the "post-function" running on service response at "header-phase".
With this plugin and post-function you can write custom logic with lua and modify the response.
With pre-function you could modify the request.
Kong have a PDK you can use globally.
Either if lb or not you would use kong.client.get_ip() or kong.client.get_forwarded_ip()
Example Code