Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some doc styles for files in doc/ #1475

Merged
merged 4 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

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
6 changes: 3 additions & 3 deletions doc/plugin-develop-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
[English](plugin-develop.md)

# 目录

- [**检查外部依赖**](#检查外部依赖)
- [**插件命名与配置**](#插件命名与配置)
- [**配置描述与校验**](#配置描述与校验)
- [**确定执行阶段**](#确定执行阶段)
- [**编写执行逻辑**](#编写执行逻辑)
- [**编写测试用例**](#编写测试用例)


## 检查外部依赖

如果你的插件,涉及到一些外部的依赖和三方库,请首先检查一下依赖项的内容。 如果插件需要用到共享内存,需要在 __bin/apisix__ 文
Expand Down Expand Up @@ -167,6 +167,7 @@ done
```

一个测试用例主要有三部分内容:

- 程序代码: Nginx location 的配置内容
- 输入: http 的 request 信息
- 输出检查: status ,header ,body ,error_log 检查
Expand All @@ -175,9 +176,8 @@ done
用例的断言是 response_body 返回 "done",__no_error_log__ 表示会对 Nginx 的 error.log 检查,
必须没有 ERROR 级别的记录。

### 附上test-nginx 执行流程
### 附上test-nginx 执行流程

根据我们在 Makefile 里配置的 PATH,和每一个 __.t__ 文件最前面的一些配置项,框架会组装成一个完整的 nginx.conf 文件,
__t/servroot__ 会被当成 Nginx 的工作目录,启动 Nginx 实例。根据测试用例提供的信息,发起 http 请求并检查 http 的返回项,
包括 http status,http response header, http response body 等。

Loading