Skip to content

Commit

Permalink
fix some doc style for response-rewrite* and health-check.md (apache#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dabue authored and SaberMaster committed Jun 30, 2020
1 parent edb18e9 commit d5dd12b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
37 changes: 19 additions & 18 deletions doc/health-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
# limitations under the License.
#
-->
## Health Checks for Upstream

# Health Checks for Upstream

Health Check of APISIX is based on [lua-resty-healthcheck](https://github.com/Kong/lua-resty-healthcheck),
you can use it for upstream.
Expand Down Expand Up @@ -77,26 +78,26 @@ contains: `active` or `passive`.

* `active`: To enable active health checks, you need to specify the configuration items under `checks.active` in the Upstream object configuration.

* `active.http_path`: The HTTP GET request path used to detect if the upstream is healthy.
* `active.host`: The HTTP request host used to detect if the upstream is healthy.
* `active.http_path`: The HTTP GET request path used to detect if the upstream is healthy.
* `active.host`: The HTTP request host used to detect if the upstream is healthy.

The threshold fields of `healthy` are:
* `active.healthy.interval`: Interval between health checks for healthy targets (in seconds), the minimum is 1.
* `active.healthy.successes`: The number of success times to determine the target is healthy, the minimum is 1.
The threshold fields of `healthy` are:
* `active.healthy.interval`: Interval between health checks for healthy targets (in seconds), the minimum is 1.
* `active.healthy.successes`: The number of success times to determine the target is healthy, the minimum is 1.

The threshold fields of `unhealthy` are:
* `active.unhealthy.interval`: Interval between health checks for unhealthy targets (in seconds), the minimum is 1.
* `active.unhealthy.http_failures`: The number of http failures times to determine the target is unhealthy, the minimum is 1.
* `active.req_headers`: Additional request headers. Array format, so you can fill in multiple headers.
The threshold fields of `unhealthy` are:
* `active.unhealthy.interval`: Interval between health checks for unhealthy targets (in seconds), the minimum is 1.
* `active.unhealthy.http_failures`: The number of http failures times to determine the target is unhealthy, the minimum is 1.
* `active.req_headers`: Additional request headers. Array format, so you can fill in multiple headers.

* `passive`: To enable passive health checks, you need to specify the configuration items under `checks.passive` in the Upstream object configuration.

The threshold fields of `healthy` are:
* `passive.healthy.http_statuses`: If the current response code is equal to any of these, set the upstream node to the `healthy` state. Otherwise ignore this request.
* `passive.healthy.successes`: Number of successes in proxied traffic (as defined by `passive.healthy.http_statuses`) to consider a target healthy, as observed by passive health checks.
The threshold fields of `healthy` are:
* `passive.healthy.http_statuses`: If the current response code is equal to any of these, set the upstream node to the `healthy` state. Otherwise ignore this request.
* `passive.healthy.successes`: Number of successes in proxied traffic (as defined by `passive.healthy.http_statuses`) to consider a target healthy, as observed by passive health checks.

The threshold fields of `unhealthy` are:
* `passive.unhealthy.http_statuses`: If the current response code is equal to any of these, set the upstream node to the `unhealthy` state. Otherwise ignore this request.
* `passive.unhealthy.tcp_failures`: Number of TCP failures in proxied traffic to consider a target unhealthy, as observed by passive health checks.
* `passive.unhealthy.timeouts`: Number of timeouts in proxied traffic to consider a target unhealthy, as observed by passive health checks.
* `passive.unhealthy.http_failures`: Number of HTTP failures in proxied traffic (as defined by `passive.unhealthy.http_statuses`) to consider a target unhealthy, as observed by passive health checks.
The threshold fields of `unhealthy` are:
* `passive.unhealthy.http_statuses`: If the current response code is equal to any of these, set the upstream node to the `unhealthy` state. Otherwise ignore this request.
* `passive.unhealthy.tcp_failures`: Number of TCP failures in proxied traffic to consider a target unhealthy, as observed by passive health checks.
* `passive.unhealthy.timeouts`: Number of timeouts in proxied traffic to consider a target unhealthy, as observed by passive health checks.
* `passive.unhealthy.http_failures`: Number of HTTP failures in proxied traffic (as defined by `passive.unhealthy.http_statuses`) to consider a target unhealthy, as observed by passive health checks.
14 changes: 9 additions & 5 deletions doc/plugins/response-rewrite-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-->

[English](response-rewrite.md)

# response-rewrite

该插件支持修改上游服务返回的 body 和 header 信息。
Expand All @@ -26,18 +27,19 @@
1、可以设置 `Access-Control-Allow-*` 等 header 信息,来实现 CORS (跨域资源共享)的功能。
2、另外也可以通过配置 status_code 和 header 里面的 Location 来实现重定向,当然如果只是需要重定向功能,最好使用 [redirect](redirect-cn.md) 插件。

#### 配置参数
## 配置参数

|名字 |可选|说明|
|------- |-----|------|
|status_code |可选| 修改上游返回状态码|
|body |可选| 修改上游返回的 `body` 内容,如果设置了新内容,header 里面的 content-length 字段也会被去掉|
|body_base64 |可选| 布尔类型,描述 `body` 字段是否需要 base64 解码之后再返回给客户端,用在某些图片和 Protobuffer 场景|
|headers |可选| 返回给客户端的 `headers`,这里可以设置多个。头信息如果存在将重写,不存在则添加。想要删除某个 header 的话,把对应的值设置为空字符串即可|

## 示例

### 示例
### 开启插件

#### 开启插件
下面是一个示例,在指定的 route 上开启了 `response rewrite` 插件:

```shell
Expand All @@ -63,15 +65,17 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
}'
```

#### 测试插件
### 测试插件

基于上述配置进行测试:

```shell
curl -X GET -i http://127.0.0.1:9080/test/index.html
```

如果看到返回的头部信息和内容都被修改了,即表示 `response rewrite` 插件生效了。
```

```shell
HTTP/1.1 200 OK
Date: Sat, 16 Nov 2019 09:15:12 GMT
Transfer-Encoding: chunked
Expand Down
10 changes: 9 additions & 1 deletion doc/plugins/response-rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@
[Chinese](response-rewrite-cn.md)

# Summary

- [**Name**](#name)
- [**Attributes**](#attributes)
- [**How To Enable**](#how-to-enable)
- [**Test Plugin**](#test-plugin)
- [**Disable Plugin**](#disable-plugin)

## Name

response rewrite plugin, rewrite the content from upstream.

**senario**:

1. can set `Access-Control-Allow-*` series field to support CORS(Cross-origin Resource Sharing).
2. we can set customized `status_code` and `Location` field in header to achieve redirect, you can alse use [redirect](redirect.md) plugin if you just want a redirection.

## Attributes

|Name |Requirement|Description|
|------- |-----|------|
|status_code |optional| New `status code` to client|
Expand All @@ -42,6 +46,7 @@ response rewrite plugin, rewrite the content from upstream.
|headers |optional| Set the new `headers` for client, can set up multiple. If it exists already from upstream, will rewrite the header, otherwise will add the header. You can set the corresponding value to an empty string to remove a header. |

## How To Enable

Here's an example, enable the `response rewrite` plugin on the specified route:

```shell
Expand All @@ -68,6 +73,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
```

## Test Plugin

Testing based on the above examples :

```shell
Expand All @@ -76,6 +82,7 @@ curl -X GET -i http://127.0.0.1:9080/test/index.html

It will output like below,no matter what kind of content from upstream.
```
HTTP/1.1 200 OK
Date: Sat, 16 Nov 2019 09:15:12 GMT
Transfer-Encoding: chunked
Expand All @@ -89,9 +96,11 @@ X-Server-status: on
This means that the `response rewrite` plugin is in effect.

## Disable Plugin

When you want to disable the `response rewrite` plugin, it is very simple,
you can delete the corresponding json configuration in the plugin configuration,
no need to restart the service, it will take effect immediately:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -107,4 +116,3 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
```

The `response rewrite` plugin has been disabled now. It works for other plugins.

0 comments on commit d5dd12b

Please sign in to comment.