This is an automated email from the ASF dual-hosted git repository.
sylviasu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new c54ed2bb2 docs: refactor uri-blocker.md (#7400)
c54ed2bb2 is described below
commit c54ed2bb2f9a6986459ae311ee1cab18268d97a9
Author: Yuedong Wu <[email protected]>
AuthorDate: Fri Jul 8 17:16:29 2022 +0800
docs: refactor uri-blocker.md (#7400)
* docs: update uri-blocker.md
---
docs/en/latest/plugins/uri-blocker.md | 2 +-
docs/zh/latest/plugins/uri-blocker.md | 45 +++++++++++++++++++----------------
2 files changed, 25 insertions(+), 22 deletions(-)
diff --git a/docs/en/latest/plugins/uri-blocker.md
b/docs/en/latest/plugins/uri-blocker.md
index b35ffdad8..e8fb38aad 100644
--- a/docs/en/latest/plugins/uri-blocker.md
+++ b/docs/en/latest/plugins/uri-blocker.md
@@ -2,7 +2,7 @@
title: uri-blocker
keywords:
- APISIX
- - Plugin
+ - API Gateway
- URI Blocker
description: This document contains information about the Apache APISIX
uri-blocker Plugin.
---
diff --git a/docs/zh/latest/plugins/uri-blocker.md
b/docs/zh/latest/plugins/uri-blocker.md
index 1cfa42763..73ce2061d 100644
--- a/docs/zh/latest/plugins/uri-blocker.md
+++ b/docs/zh/latest/plugins/uri-blocker.md
@@ -1,5 +1,10 @@
---
title: uri-blocker
+keywords:
+ - APISIX
+ - API Gateway
+ - URI Blocker
+description: 本文介绍了 Apache APISIX uri-blocker 插件的基本信息及使用方法。
---
<!--
@@ -23,20 +28,20 @@ title: uri-blocker
## 描述
-该插件可帮助我们拦截用户请求,只需要指定 `block_rules` 即可。
+`uri-blocker` 插件通过指定一系列 `block_rules` 来拦截用户请求。
## 属性
| 名称 | 类型 | 必选项 | 默认值 | 有效值 | 描述
|
| ------------- | ------------- | ------ | ------ | ---------- |
------------------------------------------------------------------- |
-| block_rules | array[string] | 必须 | | |
正则过滤数组。它们都是正则规则,如果当前请求 URI 命中任何一个,请将响应代码设置为 rejected_code
以退出当前用户请求。例如:`["root.exe", "root.m+"]`。 |
-| rejected_code | integer | 可选 | 403 | [200, ...] | 当请求 URI 命中
`block_rules` 中的任何一个时,将返回的 HTTP 状态代码。 |
-| rejected_msg | string | 可选 | | 非空 | 当请求 URI 命中 `block_rules`
中的任何一个时,将返回的 HTTP 响应体。 |
-| case_insensitive | boolean | 可选 | false | | 是否忽略大小写。当值为 true
时,在匹配请求 URI 时将忽略大小写。默认值是 false 。 |
+| block_rules | array[string] | 是 | | |
正则过滤数组。它们都是正则规则,如果当前请求 URI 命中其中任何一个,则将响应代码设置为 `rejected_code`
以退出当前用户请求。例如:`["root.exe", "root.m+"]`。 |
+| rejected_code | integer | 否 | 403 | [200, ...] | 当请求 URI 命中
`block_rules` 中的任何一个时,将返回的 HTTP 状态代码。 |
+| rejected_msg | string | 否 | | 非空 | 当请求 URI 命中 `block_rules`
中的任何一个时,将返回的 HTTP 响应体。 |
+| case_insensitive | boolean | 否 | false | | 是否忽略大小写。当设置为 `true`
时,在匹配请求 URI 时将忽略大小写。 |
-## 启用方式
+## 启用插件
-这是一个示例,在指定的路由上启用 `uri blocker` 插件:
+以下示例展示了如何在指定的路由上启用 `uri-blocker` 插件:
```shell
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
@@ -58,35 +63,35 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H
'X-API-KEY: edd1c9f034335
## 测试插件
-```shell
-$ curl -i http://127.0.0.1:9080/root.exe?a=a
-HTTP/1.1 403 Forbidden
-Date: Wed, 17 Jun 2020 13:55:41 GMT
-Content-Type: text/html; charset=utf-8
-Content-Length: 150
-Connection: keep-alive
-Server: APISIX web server
+启用并配置插件后,使用 `curl` 命令尝试访问 `block_rules` 中指定文件的 URI:
-... ...
+```shell
+curl -i http://127.0.0.1:9080/root.exe?a=a
```
-如果你设置了属性 `rejected_msg` 的值为 `"access is not allowed"` ,将会收到如下的响应体:
+如果发现返回了带有 `403` 状态码的 HTTP 响应头,则代表插件生效:
```shell
-$ curl -i http://127.0.0.1:9080/root.exe?a=a
HTTP/1.1 403 Forbidden
Date: Wed, 17 Jun 2020 13:55:41 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 150
Connection: keep-alive
Server: APISIX web server
+...
+```
+通过设置属性 `rejected_msg` 的值为 `access is not allowed`,将会收到包含如下信息的响应体:
+
+```shell
+...
{"error_msg":"access is not allowed"}
+...
```
## 禁用插件
-当想禁用 `uri blocker` 插件时,非常简单,只需要在插件配置中删除相应的 json 配置,无需重启服务,即可立即生效:
+当你需要禁用 `uri-blocker` 插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:
```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
@@ -100,5 +105,3 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H
'X-API-KEY: edd1c9f034335f13
}
}'
```
-
- `uri blocker` 插件现在已被禁用,它也适用于其他插件。