Skip to content

Commit

Permalink
add notes back
Browse files Browse the repository at this point in the history
  • Loading branch information
Yilialinn committed Feb 11, 2025
1 parent 12c091a commit ba46812
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/en/latest/plugins/real-ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.<br>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.
Expand Down
13 changes: 13 additions & 0 deletions docs/zh/latest/plugins/real-ip.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` 中发送的最后一个地址。<br>如果为 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 地址。
Expand Down

0 comments on commit ba46812

Please sign in to comment.