Adding dynamic value to Kong's IP Restriction Plugin message with X-Forwarded-For enabled

47 Views Asked by At

I am using Kong 3.5.0 as my API gateway, and I have implemented the IP Restriction Plugin to control access to my API. I want to customize the error message displayed by the plugin to include the client's IP address. The desired message format is:

"Your IP address ({ip_address}) has insufficient permissions to make this request."

I have enabled the X-Forwarded-For header, and since I am using this setup, I would like to know how to fetch the client's IP address and dynamically insert it into the message.

I tried using PreFunction plugin but no progress so far.

0

There are 0 best solutions below