real-ip Plugin is used to dynamically change the client's IP address and port as seen by APISIX.
This is more flexible but functions similarly to Nginx's ngx_http_realip_module.
This Plugin requires APISIX to run on APISIX-Base.
|source||string||True||Any Nginx variable like ||Dynamically sets the client's IP address and an optional port from APISIX's view.|
|trusted_addresses||array[string]||False||List of IPs or CIDR ranges.||Dynamically sets the |
|recursive||boolean||False||True to enable, false to disable, default is false||If recursive search is disabled, the original client address that matches one of the trusted addresses is replaced by the last address sent in the configured |
If the address specified in
source is missing or invalid, the Plugin would not change the client address.
#Enabling the Plugin
The example below enables the
real-ip Plugin on the specified Route:
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
After you have enabled the Plugin as mentioned above, you can test it as shown below:
curl 'http://127.0.0.1:9080/index.html?realip=22.214.171.124:9080' -I
To disable the
real-ip Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.
curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '