You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/07/14 13:27:36 UTC

[GitHub] [apisix] hf400159 commented on a diff in pull request #7455: docs: refactor referer-restriction.md

hf400159 commented on code in PR #7455:
URL: https://github.com/apache/apisix/pull/7455#discussion_r920612283


##########
docs/en/latest/plugins/referer-restriction.md:
##########
@@ -2,7 +2,7 @@
 title: referer-restriction
 keywords:
   - APISIX
-  - Plugin
+  - API Gateway
   - Referer restriction
   - referer-restriction

Review Comment:
   ```suggestion
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -1,5 +1,11 @@
 ---
 title: referer-restriction
+keywords:
+  - APISIX
+  - API Gateway

Review Comment:
   ```suggestion
     - API 网关
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -65,37 +74,52 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
 
 ## 测试插件
 
-带 `Referer: http://xx.com/x` 请求:
+通过上述命令启用插件后,你可以将请求设置为 `Referer: http://xx.com/x` 来测试插件:

Review Comment:
   ```suggestion
   通过上述命令启用插件后,你可以在请求中添加 `Referer: http://xx.com/x` 测试插件:
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -23,23 +29,26 @@ title: referer-restriction
 
 ## 描述
 
-`referer-restriction` 插件可以根据 Referer 请求头限制访问。
+`referer-restriction` 插件允许用户将 `Referer` 请求头列入白名单或黑名单来限制对服务或路由的访问。
 
 ## 属性
 
-| 参数名    | 类型          | 可选项 | 默认值 | 有效值 | 描述                             |
+| 参数名    | 类型          | 必选项 | 默认值 | 有效值 | 描述                             |
 | --------- | ------------- | ------ | ------ | ------ | -------------------------------- |
-| whitelist | array[string] | 可选    |         |       | 白名单域名列表。域名开头可以用'*'作为通配符。 |
-| blacklist | array[string] | 可选    |         |       | 黑名单域名列表。域名开头可以用'*'作为通配符。 |
-| message | string | 可选    | Your referer host is not allowed | [1, 1024] | 在未允许访问的情况下返回的信息。 |
-| bypass_missing  | boolean       | 可选    | false   |       | 当 Referer 不存在或格式有误时,是否绕过检查。 |
+| whitelist | array[string] | 否    |         |       | 白名单域名列表。域名开头可以用 `*` 作为通配符。 |
+| blacklist | array[string] | 否    |         |       | 黑名单域名列表。域名开头可以用 `*` 作为通配符。 |
+| message | string | 否    | "Your referer host is not allowed" | [1, 1024] | 在未允许访问的情况下返回的信息。 |
+| bypass_missing  | boolean       | 否    | false   |       | 当 `Referer` 请求头不存在或格式有误时,是否绕过检查。如果设置该选项为 `true`,那么将绕过检查。 |

Review Comment:
   ```suggestion
   | bypass_missing  | boolean       | 否    | false   |       | 当设置为 `true` 时,如果 `Referer` 请求头不存在或格式有误时,将绕过检查。 |
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -23,23 +29,26 @@ title: referer-restriction
 
 ## 描述
 
-`referer-restriction` 插件可以根据 Referer 请求头限制访问。
+`referer-restriction` 插件允许用户将 `Referer` 请求头列入白名单或黑名单来限制对服务或路由的访问。
 
 ## 属性
 
-| 参数名    | 类型          | 可选项 | 默认值 | 有效值 | 描述                             |
+| 参数名    | 类型          | 必选项 | 默认值 | 有效值 | 描述                             |
 | --------- | ------------- | ------ | ------ | ------ | -------------------------------- |
-| whitelist | array[string] | 可选    |         |       | 白名单域名列表。域名开头可以用'*'作为通配符。 |
-| blacklist | array[string] | 可选    |         |       | 黑名单域名列表。域名开头可以用'*'作为通配符。 |
-| message | string | 可选    | Your referer host is not allowed | [1, 1024] | 在未允许访问的情况下返回的信息。 |
-| bypass_missing  | boolean       | 可选    | false   |       | 当 Referer 不存在或格式有误时,是否绕过检查。 |
+| whitelist | array[string] | 否    |         |       | 白名单域名列表。域名开头可以用 `*` 作为通配符。 |

Review Comment:
   ```suggestion
   | whitelist | array[string] | 否    |         |       | 白名单域名列表。域名开头可以用 `*` 作为通配符。`whitelist` 和 `blacklist` 必须设置一个。 |
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -23,23 +29,26 @@ title: referer-restriction
 
 ## 描述
 
-`referer-restriction` 插件可以根据 Referer 请求头限制访问。
+`referer-restriction` 插件允许用户将 `Referer` 请求头列入白名单或黑名单来限制对服务或路由的访问。
 
 ## 属性
 
-| 参数名    | 类型          | 可选项 | 默认值 | 有效值 | 描述                             |
+| 参数名    | 类型          | 必选项 | 默认值 | 有效值 | 描述                             |
 | --------- | ------------- | ------ | ------ | ------ | -------------------------------- |
-| whitelist | array[string] | 可选    |         |       | 白名单域名列表。域名开头可以用'*'作为通配符。 |
-| blacklist | array[string] | 可选    |         |       | 黑名单域名列表。域名开头可以用'*'作为通配符。 |
-| message | string | 可选    | Your referer host is not allowed | [1, 1024] | 在未允许访问的情况下返回的信息。 |
-| bypass_missing  | boolean       | 可选    | false   |       | 当 Referer 不存在或格式有误时,是否绕过检查。 |
+| whitelist | array[string] | 否    |         |       | 白名单域名列表。域名开头可以用 `*` 作为通配符。 |
+| blacklist | array[string] | 否    |         |       | 黑名单域名列表。域名开头可以用 `*` 作为通配符。 |

Review Comment:
   ```suggestion
   | blacklist | array[string] | 否    |         |       | 黑名单域名列表。域名开头可以用 `*` 作为通配符。`whitelist` 和 `blacklist` 必须设置一个。|
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -65,37 +74,52 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
 
 ## 测试插件
 
-带 `Referer: http://xx.com/x` 请求:
+通过上述命令启用插件后,你可以将请求设置为 `Referer: http://xx.com/x` 来测试插件:
+
+```shell
+curl http://127.0.0.1:9080/index.html -H 'Referer: http://xx.com/x'
+```
+
+返回的 HTTP 响应头中带有 `200` 状态码,代表访问成功:

Review Comment:
   ```suggestion
   返回的 HTTP 响应头中带有 `200` 状态码则表示访问成功:
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -1,5 +1,11 @@
 ---
 title: referer-restriction
+keywords:
+  - APISIX
+  - API Gateway
+  - Referer restriction
+  - referer-restriction
+description: 本文介绍了 Apache APISIX referer-restriction 插件的基本信息及使用方法。

Review Comment:
   ```suggestion
   description: 本文介绍了 Apache APISIX referer-restriction 插件的使用方法,通过该插件可以将 referer 请求头中的域名加入黑名单或者白名单来限制其对服务或路由的访问。
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -65,37 +74,52 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
 
 ## 测试插件
 
-带 `Referer: http://xx.com/x` 请求:
+通过上述命令启用插件后,你可以将请求设置为 `Referer: http://xx.com/x` 来测试插件:
+
+```shell
+curl http://127.0.0.1:9080/index.html -H 'Referer: http://xx.com/x'
+```
+
+返回的 HTTP 响应头中带有 `200` 状态码,代表访问成功:
 
 ```shell
-$ curl http://127.0.0.1:9080/index.html -H 'Referer: http://xx.com/x'
 HTTP/1.1 200 OK
 ...
 ```
 
-带 `Referer: http://yy.com/x` 请求:
+接下来,将请求设置为 `Referer: http://yy.com/x`:
+
+```shell
+curl http://127.0.0.1:9080/index.html -H 'Referer: http://yy.com/x'
+```
+
+返回的 HTTP 响应头中带有 `403` 状态码,并在响应体中带有 `message` 属性值,代表访问被阻止:
 
 ```shell
-$ curl http://127.0.0.1:9080/index.html -H 'Referer: http://yy.com/x'
 HTTP/1.1 403 Forbidden
 ...
 {"message":"Your referer host is not allowed"}
 ```
 
-不带 `Referer` 请求:
+因为启用插件时将属性 `bypass_missing` 设置为 `true`,所以未指定 `Refer` 请求头的请求将跳过检查:
+
+```shell
+curl http://127.0.0.1:9080/index.html
+```
+
+返回的 HTTP 响应头中带有 `200` 状态码,代表访问成功:
 
 ```shell
-$ curl http://127.0.0.1:9080/index.html
 HTTP/1.1 200 OK
 ...
 ```
 
 ## 禁用插件
 
-当你想去掉 `referer-restriction` 插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
+当你需要禁用 `referer-restriction` 插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:

Review Comment:
   ```suggestion
   当你需要禁用该插件时,可以通过以下命令删除相应的 JSON 配置,APISIX 将会自动重新加载相关配置,无需重启服务:
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -23,23 +29,26 @@ title: referer-restriction
 
 ## 描述
 
-`referer-restriction` 插件可以根据 Referer 请求头限制访问。
+`referer-restriction` 插件允许用户将 `Referer` 请求头列入白名单或黑名单来限制对服务或路由的访问。

Review Comment:
   ```suggestion
   `referer-restriction` 插件允许用户将 `Referer` 请求头中的域名列入白名单或黑名单来限制该域名对服务或路由的访问。
   ```



##########
docs/en/latest/plugins/referer-restriction.md:
##########
@@ -2,7 +2,7 @@
 title: referer-restriction
 keywords:
   - APISIX
-  - Plugin
+  - API Gateway
   - Referer restriction
   - referer-restriction
 description: This document contains information about the Apache APISIX referer-restriction Plugin.

Review Comment:
   Please refer to the Chinese modification, keep the characters between 130 and 150.



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -1,5 +1,11 @@
 ---
 title: referer-restriction
+keywords:
+  - APISIX
+  - API Gateway
+  - Referer restriction
+  - referer-restriction

Review Comment:
   ```suggestion
   ```



##########
docs/zh/latest/plugins/referer-restriction.md:
##########
@@ -23,23 +29,26 @@ title: referer-restriction
 
 ## 描述
 
-`referer-restriction` 插件可以根据 Referer 请求头限制访问。
+`referer-restriction` 插件允许用户将 `Referer` 请求头列入白名单或黑名单来限制对服务或路由的访问。
 
 ## 属性
 
-| 参数名    | 类型          | 可选项 | 默认值 | 有效值 | 描述                             |
+| 参数名    | 类型          | 必选项 | 默认值 | 有效值 | 描述                             |
 | --------- | ------------- | ------ | ------ | ------ | -------------------------------- |
-| whitelist | array[string] | 可选    |         |       | 白名单域名列表。域名开头可以用'*'作为通配符。 |
-| blacklist | array[string] | 可选    |         |       | 黑名单域名列表。域名开头可以用'*'作为通配符。 |
-| message | string | 可选    | Your referer host is not allowed | [1, 1024] | 在未允许访问的情况下返回的信息。 |
-| bypass_missing  | boolean       | 可选    | false   |       | 当 Referer 不存在或格式有误时,是否绕过检查。 |
+| whitelist | array[string] | 否    |         |       | 白名单域名列表。域名开头可以用 `*` 作为通配符。 |
+| blacklist | array[string] | 否    |         |       | 黑名单域名列表。域名开头可以用 `*` 作为通配符。 |
+| message | string | 否    | "Your referer host is not allowed" | [1, 1024] | 在未允许访问的情况下返回的信息。 |
+| bypass_missing  | boolean       | 否    | false   |       | 当 `Referer` 请求头不存在或格式有误时,是否绕过检查。如果设置该选项为 `true`,那么将绕过检查。 |

Review Comment:
   If set to false, what happens when the `Referer` request header does not exist?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org