Skip to content

Commit

Permalink
doc: fix some doc styles for files in doc/ (#1475)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabue authored Apr 20, 2020
1 parent ea97645 commit 46a94d1
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 41 deletions.
12 changes: 6 additions & 6 deletions doc/admin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#
-->

# Table of Contents

Table of contents
===

* [Route](#route)
Expand Down Expand Up @@ -167,7 +167,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```

[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)

## Service

Expand Down Expand Up @@ -245,7 +245,7 @@ Server: APISIX web server
Return response from etcd currently.

[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)

## Consumer

Expand Down Expand Up @@ -312,7 +312,7 @@ Date: Thu, 26 Dec 2019 08:17:49 GMT
Return response from etcd currently.

[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)

## Upstream

Expand Down Expand Up @@ -392,7 +392,7 @@ Content-Type: text/plain
Return response from etcd currently.

[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)

## SSL

Expand Down Expand Up @@ -428,4 +428,4 @@ Config Example:
}
```

[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)
30 changes: 25 additions & 5 deletions doc/architecture-design-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#
-->

## 目录
# 目录

- [**APISIX**](#apisix)
- [**APISIX Config**](#apisix-config)
- [**Route**](#route)
Expand All @@ -33,7 +34,7 @@

### 插件加载流程

![](./images/flow-load-plugin.png)
![插件加载流程](./images/flow-load-plugin.png)

### 插件内部结构

Expand Down Expand Up @@ -230,7 +231,7 @@ Upstream 是虚拟主机抽象,对给定的多个服务节点按照配置规
Upstream 的配置可以被直接绑定在指定 `Route` 中,也可以被绑定在 `Service` 中,不过 `Route` 中的配置
优先级更高。这里的优先级行为与 `Plugin` 非常相似

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

APISIX 的 Upstream 除了基本的复杂均衡算法选择外,还支持对上游做主被动健康检查、重试等逻辑,具体看下面表格。

Expand All @@ -245,6 +246,7 @@ APISIX 的 Upstream 除了基本的复杂均衡算法选择外,还支持对上
|enable_websocket|可选| 是否启用 `websocket`(布尔值),默认不启用|

`hash_on` 比较复杂,这里专门说明下:

1. 设为 `vars` 时,`key` 为必传参数,目前支持的 Nginx 内置变量有 `uri, server_name, server_addr, request_uri, remote_port, remote_addr, query_string, host, hostname, arg_***`,其中 `arg_***` 是来自URL的请求参数,[Nginx 变量列表](http://nginx.org/en/docs/varindex.html)
1. 设为 `header` 时, `key` 为必传参数,其值为自定义的 header name, 即 "http_`key`"
1. 设为 `cookie` 时, `key` 为必传参数,其值为自定义的 cookie name,即 "cookie_`key`"
Expand Down Expand Up @@ -310,6 +312,7 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
```

下面是一个配置了健康检查的示例:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand Down Expand Up @@ -345,11 +348,15 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}
}'
```

更多细节可以参考[健康检查的文档](health-check.md)

下面是几个使用不同`hash_on`类型的配置示例:
##### Consumer

#### Consumer

创建一个consumer对象:

```shell
curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d `
{
Expand All @@ -361,7 +368,9 @@ curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f1
}
}`
```

新建路由,打开`key-auth`插件认证,`upstream``hash_on`类型为`consumer`

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -379,13 +388,17 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
"uri": "/server_port"
}'
```

测试请求,认证通过后的`consumer_id`将作为负载均衡哈希算法的哈希值:

```shell
curl http://127.0.0.1:9080/server_port -H "apikey: auth-jack"
```

##### Cookie

新建路由和`Upstream``hash_on`类型为`cookie`

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -403,12 +416,15 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
```

客户端请求携带`Cookie`

```shell
curl http://127.0.0.1:9080/hash_on_cookie -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -H "Cookie: sid=3c183a30cffcda1408daf1c61d47b274"
```

##### Header

新建路由和`Upstream``hash_on`类型为`header``key``content-type`

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -426,13 +442,13 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
```

客户端请求携带`content-type``header`

```shell
curl http://127.0.0.1:9080/hash_on_header -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -H "Content-Type: application/json"
```

[返回目录](#目录)


## Router

APISIX 区别于其他 API 网关的一大特点是允许用户选择不同 Router 来更好匹配自由业务,在性能、自由之间做最适合选择。
Expand Down Expand Up @@ -531,8 +547,10 @@ HTTP/1.1 503 Service Temporarily Unavailable
[返回目录](#目录)

## Global Rule

[Plugin](#Plugin) 只能绑定在 [Service](#Service) 或者 [Route](#Route) 上,如果我们需要一个能作用于所有请求的 [Plugin](#Plugin) 该怎么办呢?
这时候我们可以使用 `GlobalRule` 来注册一个全局的 [Plugin](#Plugin):

```shell
curl -X PUT \
https://{apisix_listen_address}/apisix/admin/global_rules/1 \
Expand All @@ -549,9 +567,11 @@ curl -X PUT \
}
}'
```

如上所注册的 `limit-count` 插件将会作用于所有的请求。

我们可以通过以下接口查看所有的 `GlobalRule`:

```shell
curl https://{apisix_listen_address}/apisix/admin/global_rules
```
Expand Down
30 changes: 24 additions & 6 deletions doc/architecture-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
[Chinese](architecture-design-cn.md)

## Table of Contents

- [**APISIX**](#apisix)
- [**APISIX Config**](#apisix-config)
- [**Route**](#route)
Expand All @@ -35,7 +36,7 @@

### Plugin Loading Process

![](./images/flow-load-plugin.png)
![flow-load-plugin](./images/flow-load-plugin.png)

### Plugin Hierarchy Structure

Expand Down Expand Up @@ -225,7 +226,7 @@ As shown in the image above, by creating an Upstream object and referencing it b

Upstream configuration can be directly bound to the specified `Route` or it can be bound to `Service`, but the configuration in `Route` has a higher priority. The priority behavior here is very similar to `Plugin`.

#### Configuration
### Configuration

In addition to the basic complex equalization algorithm selection, APISIX's Upstream also supports logic for upstream passive health check and retry, see the table below.

Expand Down Expand Up @@ -340,8 +341,11 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
More details can be found in [Health Checking Documents](health-check.md).

Here are some examples of configurations using different `hash_on` types:
##### Consumer

#### Consumer

Create a consumer object:

```shell
curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d `
{
Expand All @@ -353,7 +357,9 @@ curl http://127.0.0.1:9080/apisix/admin/consumers -H 'X-API-KEY: edd1c9f034335f1
}
}`
```

Create route object and enable `key-auth` plugin authentication:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -371,13 +377,17 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
"uri": "/server_port"
}'
```

Test request, the `consumer_id` after authentication is passed will be used as the hash value of the load balancing hash algorithm:

```shell
curl http://127.0.0.1:9080/server_port -H "apikey: auth-jack"
```

##### Cookie
#### Cookie

Create route and upstream object, `hash_on` is `cookie`:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -393,13 +403,17 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}
}'
```

The client requests with `Cookie`:

```shell
curl http://127.0.0.1:9080/hash_on_cookie -H "Cookie: sid=3c183a30cffcda1408daf1c61d47b274"
```

##### Header
#### Header

Create route and upstream object, `hash_on` is `header`, `key` is `Content-Type`:

```shell
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand All @@ -417,13 +431,13 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
```

The client requests with header `Content-Type`:

```shell
curl http://127.0.0.1:9080/hash_on_header -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -H "Content-Type: application/json"
```

[Back to top](#Table-of-contents)


## Router

A distinguishing feature of APISIX from other API gateways is that it allows users to choose different routers to better match free services, making the best choice between performance and freedom.
Expand Down Expand Up @@ -522,8 +536,10 @@ HTTP/1.1 503 Service Temporarily Unavailable
[Back to top](#Table-of-contents)

## Global Rule

[Plugin](#Plugin) just can be binded to [Service](#Service) or [Route](#Route), if we want a [Plugin](#Plugin) work on all requests, how to do it?
We can register a global [Plugin](#Plugin) with `GlobalRule`:

```shell
curl -X PUT \
https://{apisix_listen_address}/apisix/admin/global_rules/1 \
Expand All @@ -540,9 +556,11 @@ curl -X PUT \
}
}'
```

Now, the `limit-count` plugin will work on all requets

we can list all `GlobalRule` via admin api as below:

```shell
curl https://{apisix_listen_address}/apisix/admin/global_rules
```
Expand Down
7 changes: 2 additions & 5 deletions doc/grpc-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
-->

[中文](grpc-proxy-cn.md)

# grpc-proxy

proxying gRPC traffic:
gRPC client -> APISIX -> gRPC server

### Parameters
## Parameters

* `service_protocol`: the route's option `service_protocol` must be `grpc`
* `uri`: format likes /service/method , Example:/helloworld.Greeter/SayHello



### Example

#### create proxying gRPC route
Expand All @@ -55,7 +54,6 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f13
}'
```


#### testing

Invoking the route created before:
Expand All @@ -68,4 +66,3 @@ $ grpcurl -insecure -import-path /pathtoprotos -proto helloworld.proto -d '{"n
```

This means that the proxying is working.

2 changes: 0 additions & 2 deletions doc/health-check.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# limitations under the License.
#
-->


## Health Checks for Upstream

Health Check of APISIX is based on [lua-resty-healthcheck](https://github.com/Kong/lua-resty-healthcheck),
Expand Down
1 change: 1 addition & 0 deletions doc/https-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-->

[English](https.md)

### HTTPS

`APISIX` 支持通过 TLS 扩展 SNI 实现加载特定的 SSL 证书以实现对 https 的支持。
Expand Down
2 changes: 1 addition & 1 deletion doc/https.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
-->

[Chinese](https-cn.md)

### HTTPS

`APISIX` supports to load a specific SSL certificate by TLS extension Server Name Indication (SNI).
Expand Down Expand Up @@ -67,7 +68,6 @@ that means it can accept more than one domain, eg: `www.test.com` or `mail.test.
Here is an example, please pay attention on the field `sni`.
```shell
curl http://127.0.0.1:9080/apisix/admin/ssl/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
Expand Down
Loading

0 comments on commit 46a94d1

Please sign in to comment.