doc: fix some doc styles for files in doc/ (#1475)

This commit is contained in:
dabue 2020-04-19 20:07:42 -05:00 committed by GitHub
parent ea97645137
commit 46a94d1bb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 90 additions and 41 deletions

View File

@ -17,8 +17,8 @@
#
-->
# Table of Contents
Table of contents
===
* [Route](#route)
@ -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
@ -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
@ -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
@ -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
@ -428,4 +428,4 @@ Config Example:
}
```
[Back to TOC](#table-of-contents)
[Back to TOC](#Table-of-Contents)

View File

@ -17,7 +17,8 @@
#
-->
## 目录
# 目录
- [**APISIX**](#apisix)
- [**APISIX Config**](#apisix-config)
- [**Route**](#route)
@ -33,7 +34,7 @@
### 插件加载流程
![](./images/flow-load-plugin.png)
![插件加载流程](./images/flow-load-plugin.png)
### 插件内部结构
@ -230,7 +231,7 @@ Upstream 是虚拟主机抽象,对给定的多个服务节点按照配置规
Upstream 的配置可以被直接绑定在指定 `Route` 中,也可以被绑定在 `Service` 中,不过 `Route` 中的配置
优先级更高。这里的优先级行为与 `Plugin` 非常相似
#### 配置参数
### 配置参数
APISIX 的 Upstream 除了基本的复杂均衡算法选择外,还支持对上游做主被动健康检查、重试等逻辑,具体看下面表格。
@ -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`"
@ -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 '
{
@ -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 `
{
@ -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 '
{
@ -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 '
{
@ -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 '
{
@ -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 来更好匹配自由业务,在性能、自由之间做最适合选择。
@ -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 \
@ -549,9 +567,11 @@ curl -X PUT \
}
}'
```
如上所注册的 `limit-count` 插件将会作用于所有的请求。
我们可以通过以下接口查看所有的 `GlobalRule`:
```shell
curl https://{apisix_listen_address}/apisix/admin/global_rules
```

View File

@ -20,6 +20,7 @@
[Chinese](architecture-design-cn.md)
## Table of Contents
- [**APISIX**](#apisix)
- [**APISIX Config**](#apisix-config)
- [**Route**](#route)
@ -35,7 +36,7 @@
### Plugin Loading Process
![](./images/flow-load-plugin.png)
![flow-load-plugin](./images/flow-load-plugin.png)
### Plugin Hierarchy Structure
@ -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.
@ -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 `
{
@ -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 '
{
@ -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 '
{
@ -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 '
{
@ -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.
@ -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 \
@ -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
```

View File

@ -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
@ -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
@ -68,4 +66,3 @@ $ grpcurl -insecure -import-path /pathtoprotos -proto helloworld.proto -d '{"n
```
This means that the proxying is working.

View File

@ -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),

View File

@ -18,6 +18,7 @@
-->
[English](https.md)
### HTTPS
`APISIX` 支持通过 TLS 扩展 SNI 实现加载特定的 SSL 证书以实现对 https 的支持。

View File

@ -18,6 +18,7 @@
-->
[Chinese](https-cn.md)
### HTTPS
`APISIX` supports to load a specific SSL certificate by TLS extension Server Name Indication (SNI).
@ -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 '
{

View File

@ -19,6 +19,7 @@
[English](plugin-develop.md)
# 目录
- [**检查外部依赖**](#检查外部依赖)
- [**插件命名与配置**](#插件命名与配置)
- [**配置描述与校验**](#配置描述与校验)
@ -26,7 +27,6 @@
- [**编写执行逻辑**](#编写执行逻辑)
- [**编写测试用例**](#编写测试用例)
## 检查外部依赖
如果你的插件,涉及到一些外部的依赖和三方库,请首先检查一下依赖项的内容。 如果插件需要用到共享内存,需要在 __bin/apisix__
@ -167,6 +167,7 @@ done
```
一个测试用例主要有三部分内容:
- 程序代码: Nginx location 的配置内容
- 输入: http 的 request 信息
- 输出检查: status header body error_log 检查
@ -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 statushttp response header http response body 等。

View File

@ -19,6 +19,7 @@
[中文](plugin-develop-cn.md)
# table of contents
- [**check dependencies**](#check-dependencies)
- [**name and config**](#name-and-config)
- [**schema and check**](#schema-and-check)
@ -26,7 +27,6 @@
- [**implement the logic**](#implement-the-logic)
- [**write test case**](#write-test-case)
## check dependencies
if you have dependencies on external libraries, check the dependent items. if your plugin needs to use shared memory, it
@ -183,6 +183,7 @@ done
```
A test case consists of three parts :
- __Program code__ : configuration content of Nginx location
- __Input__ : http request information
- __Output check__ : status, header, body, error log check

View File

@ -24,6 +24,7 @@
APISIX 的插件是热加载的,不管你是新增、删除还是修改插件,都不需要重启服务。
只需要通过 admin API 发送一个 HTTP 请求即可:
```shell
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
```

View File

@ -20,9 +20,11 @@
[Chinese](plugins-cn.md)
## Hot reload
APISIX plug-ins are hot-loaded. No matter you add, delete or modify plug-ins, you don't need to restart the service.
Just send an HTTP request through admin API:
```shell
curl http://127.0.0.1:9080/apisix/admin/plugins/reload -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT
```

View File

@ -18,12 +18,13 @@
-->
[English](limit-count.md)
# limit-count
和 [GitHub API 的限速](https://developer.github.com/v3/#rate-limiting)类似,
在指定的时间范围内,限制总的请求个数。并且在 HTTP 响应头中返回剩余可以请求的个数。
### 参数
## 参数
|名称 |可选项 |说明|
|--------- |--------|-----------|
@ -40,6 +41,7 @@
### 示例
#### 开启插件
下面是一个示例,在指定的 `route` 上开启了 `limit count` 插件:
```shell
@ -64,10 +66,10 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
```
你可以使用浏览器打开 dashboard`http://127.0.0.1:9080/apisix/dashboard/`,通过 web 界面来完成上面的操作,先增加一个 route
![](../images/plugin/limit-count-1.png)
![添加路由](../images/plugin/limit-count-1.png)
然后在 route 页面中添加 limit-count 插件:
![](../images/plugin/limit-count-2.png)
![添加插件](../images/plugin/limit-count-2.png)
如果你需要一个集群级别的流量控制,我们可以借助 redis server 来完成。不同的 APISIX 节点之间将共享流量限速结果,实现集群流量限速。
@ -100,12 +102,15 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
```
#### 测试插件
上述配置限制了 60 秒内只能访问 2 次,前两次访问都会正常访问:
```shell
curl -i http://127.0.0.1:9080/index.html
```
响应头里面包含了 `X-RateLimit-Limit``X-RateLimit-Remaining`,他们的含义分别是限制的总请求数和剩余还可以发送的请求数:
```
HTTP/1.1 200 OK
Content-Type: text/html
@ -117,6 +122,7 @@ Server: APISIX web server
```
当你第三次访问的时候,就会收到包含 503 返回码的响应头:
```
HTTP/1.1 503 Service Temporarily Unavailable
Content-Type: text/html
@ -136,6 +142,7 @@ Server: APISIX web server
这就表示 `limit count` 插件生效了。
#### 移除插件
当你想去掉 `limit count` 插件的时候,很简单,在插件的配置中把对应的 json 配置删除即可,无须重启服务,即刻生效:
```shell

View File

@ -20,6 +20,7 @@
[Chinese](limit-count-cn.md)
# Summary
- [**Name**](#name)
- [**Attributes**](#attributes)
- [**How To Enable**](#how-to-enable)
@ -70,10 +71,10 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
```
You can open dashboard with a browser: `http://127.0.0.1:9080/apisix/dashboard/`, to complete the above operation through the web interface, first add a route:
![](../images/plugin/limit-count-1.png)
![Add a router.](../images/plugin/limit-count-1.png)
Then add limit-count plugin:
![](../images/plugin/limit-count-2.png)
![Add limit-count plugin.](../images/plugin/limit-count-2.png)
If you need a cluster-level precision traffic limit, then we can do it with the redis server. The rate limit of the traffic will be shared between different APISIX nodes to limit the rate of cluster traffic.
@ -106,13 +107,16 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
```
## Test Plugin
The above configuration limits access to only 2 times in 60 seconds. The first two visits will be normally:
```shell
curl -i http://127.0.0.1:9080/index.html
```
The response header contains `X-RateLimit-Limit` and `X-RateLimit-Remaining`,
which mean the total number of requests and the remaining number of requests that can be sent:
```
HTTP/1.1 200 OK
Content-Type: text/html
@ -124,6 +128,7 @@ Server: APISIX web server
```
When you visit for the third time, you will receive a response with the 503 HTTP code:
```
HTTP/1.1 503 Service Temporarily Unavailable
Content-Type: text/html
@ -143,9 +148,11 @@ Server: APISIX web server
This means that the `limit count` plugin is in effect.
## Disable Plugin
When you want to disable the `limit count` 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 '
{

View File

@ -23,10 +23,8 @@
如果把所有环境的配置都放在同一个文件里,非常不好管理,我们接到新需求后,在开发环境进行开发时,需要将配置文件中的参数都改成开发环境的,提交代码时还要改回去,这样改来改去非常容易出错。
上述问题的解决办法就是通过环境变量来区分当前运行环境并通过环境变量来切换不同配置文件。APISIX 中对应的环境变量就是:`APISIX_PROFILE`。
在没有设置`APISIX_PROFILE` 时,默认使用以下三个配置文件:
* conf/config.yaml

View File

@ -30,14 +30,13 @@ development environment. You have to change it back. It's very easy to make mist
The solution to the above problem is to distinguish the current running environment through environment variables, and switch
between different configuration files through environment variables. The corresponding environment variable in APISIX is: `APISIX_PROFILE`
When `APISIX_PROFILE` is not set, the following three configuration files are used by default:
* conf/config.yaml
* conf/apisix.yaml
* conf/debug.yaml
If the value of `APISIX_PROFILE` is set to` prod`, the following three configuration files are used:
If the value of `APISIX_PROFILE` is set to `prod`, the following three configuration files are used:
* conf/config-prod.yaml
* conf/apisix-prod.yaml

View File

@ -68,7 +68,6 @@ Here are the rules:
|/blog/foo/gloo | `/blog/foo/*` |
|/blog/bar | not match |
### How to filter route by Nginx builtin variable
Please take a look at [radixtree-new](https://github.com/iresty/lua-resty-radixtree#new),

View File

@ -30,7 +30,7 @@ APISIX 可以对 TCP/UDP 协议进行代理并实现动态负载均衡。 在 ng
`conf/config.yaml` 配置文件设置 `stream_proxy` 选项, 指定一组需要进行动态代理的IP地址。默认情况不开启stream代理。
```
```yaml
apisix:
stream_proxy: # TCP/UDP proxy
tcp: # TCP proxy address list
@ -78,4 +78,5 @@ curl http://127.0.0.1:9080/apisix/admin/stream_routes/1 -H 'X-API-KEY: edd1c9f03
}
}'
```
例子中 APISIX 把上游地址 `127.0.0.1:1995` 代理成地址为 `127.0.0.1`, 端口为 `2000`

View File

@ -30,7 +30,7 @@ APISIX can dynamic load balancing TCP/UDP proxy. In Nginx world, we call TCP/UDP
Setting the `stream_proxy` option in `conf/config.yaml`, specify a list of addresses that require dynamic proxy.
By default, no any stream proxy is enabled.
```
```yaml
apisix:
stream_proxy: # TCP/UDP proxy
tcp: # TCP proxy address list