SylviaBABY commented on code in PR #7455: URL: https://github.com/apache/apisix/pull/7455#discussion_r921734794
########## 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` 请求头的请求将跳过检查: Review Comment: ```suggestion 因为启用插件时会将属性 `bypass_missing` 设置为 `true`,所以未指定 `Refer` 请求头的请求将跳过检查: ``` -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org