diff --git a/docs/en/latest/plugins/real-ip.md b/docs/en/latest/plugins/real-ip.md index eb91dcab8af1..a03ad13d26ee 100644 --- a/docs/en/latest/plugins/real-ip.md +++ b/docs/en/latest/plugins/real-ip.md @@ -45,10 +45,23 @@ The Plugin is functionally similar to NGINX's [ngx_http_realip_module](https://n | trusted_addresses | array[string] | False | | array of IPv4 or IPv6 addresses (CIDR notation acceptable) | Trusted addresses that are known to send correct replacement addresses. This configuration sets the [`set_real_ip_from`](https://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from) directive. | | recursive | boolean | False | False | | If false, replace the original client address that matches one of the trusted addresses by the last address sent in the configured `source`.
If true, replace the original client address that matches one of the trusted addresses by the last non-trusted address sent in the configured `source`. | +:::note +If the address specified in `source` is missing or invalid, the Plugin would not change the client address. +::: + ## Examples The examples below demonstrate how you can configure `real-ip` in different scenarios. +:::note +You can fetch the `admin_key` from `config.yaml` and save to an environment variable with the following command: + +```bash +admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 's/"//g') +``` + +::: + ### Obtain Real Client Address From URI Parameter The following example demonstrates how to update the client IP address with a URI parameter. diff --git a/docs/zh/latest/plugins/real-ip.md b/docs/zh/latest/plugins/real-ip.md index b31c8a7834e1..8e756528f96c 100644 --- a/docs/zh/latest/plugins/real-ip.md +++ b/docs/zh/latest/plugins/real-ip.md @@ -45,10 +45,23 @@ description: real-ip 插件允许 Apache APISIX 通过 HTTP 请求头或 HTTP | trusted_addresses | array[string] | 否 | | IPv4 或 IPv6 地址数组(接受 CIDR 表示法) | 已知会发送正确替代地址的可信地址。此配置设置 [`set_real_ip_from`](https://nginx.org/en/docs/http/ngx_http_realip_module.html#set_real_ip_from) 指令。 | | recursive | boolean | 否 | false | | 如果为 false,则将匹配可信地址之一的原始客户端地址替换为配置的 `source` 中发送的最后一个地址。
如果为 true,则将匹配可信地址之一的原始客户端地址替换为配置的 `source` 中发送的最后一个非可信地址。 | +:::note +如果 `source` 属性中设置的地址丢失或者无效,该插件将不会更改客户端地址。 +::: + ## 示例 以下示例展示了如何在不同场景中配置 `real-ip`。 +:::note +您可以这样从 `config.yaml` 中获取 `admin_key` 并存入环境变量: + +```bash +admin_key=$(yq '.deployment.admin.admin_key[0].key' conf/config.yaml | sed 's/"//g') +``` + +::: + ### 从 URI 参数获取真实客户端地址 以下示例演示了如何使用 URI 参数更新客户端 IP 地址。