This is an automated email from the ASF dual-hosted git repository.
spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new d68016e docs: enrich stand alone mode's doc (#3264)
d68016e is described below
commit d68016e57930457806bf7a2381fee5fb68814f56
Author: 罗泽轩 <[email protected]>
AuthorDate: Wed Jan 13 00:49:33 2021 -0600
docs: enrich stand alone mode's doc (#3264)
---
doc/stand-alone.md | 81 ++++++++++++++++++++--
doc/zh-cn/stand-alone.md | 75 ++++++++++++++++++--
.../{stream-route.t => plugin-metadata.t} | 78 ++++++---------------
t/config-center-yaml/stream-route.t | 27 ++++++++
4 files changed, 195 insertions(+), 66 deletions(-)
diff --git a/doc/stand-alone.md b/doc/stand-alone.md
index cafef45..1538f66 100644
--- a/doc/stand-alone.md
+++ b/doc/stand-alone.md
@@ -46,7 +46,7 @@ apisix:
In addition, since the current Admin API is based on the etcd configuration
center solution, enable Admin API is not allowed when the Stand-alone mode is
enabled.
-## How to config rules
+### How to configure rules
All of the rules are stored in one file which named `conf/apisix.yaml`,
the APISIX will check if this file has any changed every second.
@@ -68,7 +68,7 @@ routes:
*NOTE*: APISIX will not load the rules into memory from file
`conf/apisix.yaml` if there is no `#END` at the end.
-#### How to config Router
+### How to configure Router
Single Router:
@@ -102,7 +102,7 @@ routes:
#END
```
-#### How to config Router + Service
+### How to configure Router + Service
```yml
routes:
@@ -119,7 +119,7 @@ services:
#END
```
-#### How to config Router + Upstream
+### How to configure Router + Upstream
```yml
routes:
@@ -135,7 +135,7 @@ upstreams:
#END
```
-#### How to config Router + Service + Upstream
+### How to configure Router + Service + Upstream
```yml
routes:
@@ -155,7 +155,7 @@ upstreams:
#END
```
-#### How to config Plugins
+### How to configure Plugins
```yml
# plugins listed here will be hot reloaded and override the boot configuration
@@ -167,7 +167,7 @@ plugins:
#END
```
-#### How to enable SSL
+### How to enable SSL
```yml
ssl:
@@ -228,3 +228,70 @@ ssl:
- "yourdomain.com"
#END
```
+
+### How to configure global rule
+
+```yaml
+global_rules:
+ -
+ id: 1
+ plugins:
+ response-rewrite:
+ body: "hello\n"
+```
+
+### How to configure consumer
+
+```yaml
+consumers:
+ - username: jwt
+ plugins:
+ jwt-auth:
+ key: user-key
+ secret: my-secret-key
+```
+
+### How to configure plugin metadata
+
+```yaml
+upstreams:
+ - id: 1
+ nodes:
+ "127.0.0.1:1980": 1
+ type: roundrobin
+routes:
+ -
+ uri: /hello
+ upstream_id: 1
+ plugins:
+ http-logger:
+ batch_max_size: 1
+ uri: http://127.0.0.1:1980/log
+plugin_metadata:
+ - id: http-logger # note the id is the plugin name
+ log_format:
+ host: "$host",
+ remote_addr: "$remote_addr"
+```
+
+### How to configure stream route
+
+```yaml
+stream_routes:
+ - server_addr: 127.0.0.1
+ server_port: 1985
+ id: 1
+ upstream_id: 1
+ plugins:
+ mqtt-proxy:
+ protocol_name: "MQTT"
+ protocol_level: 4
+ upstream:
+ ip: "127.0.0.1"
+ port: 1995
+upstreams:
+ - nodes:
+ "127.0.0.1:1995": 1
+ type: roundrobin
+ id: 1
+```
diff --git a/doc/zh-cn/stand-alone.md b/doc/zh-cn/stand-alone.md
index 9355e30..fb4c562 100644
--- a/doc/zh-cn/stand-alone.md
+++ b/doc/zh-cn/stand-alone.md
@@ -49,7 +49,7 @@ apisix:
此外由于目前 Admin API 都是基于 etcd 配置中心解决方案,当开启 Stand-alone 模式后,
Admin API 将不再被允许使用。
-## 如何配置规则
+### 如何配置规则
所有的路由规则均存放在 `conf/apisix.yaml` 这一个文件中,APISIX
会以每秒(默认)频率检查文件是否有变化,如果有变化,则会检查文件末尾是否能找到 `#END` 结尾,找到后则重新加载文件更新到内存。
@@ -135,7 +135,7 @@ upstreams:
#END
```
-#### 配置 Router + Service + Upstream
+### 配置 Router + Service + Upstream
```yml
routes:
@@ -155,7 +155,7 @@ upstreams:
#END
```
-#### 配置 Plugins
+### 配置 Plugins
```yml
# 列出的插件会被热加载并覆盖掉启动时的配置
@@ -167,7 +167,7 @@ plugins:
#END
```
-#### 启用 SSL
+### 启用 SSL
```yml
ssl:
@@ -228,3 +228,70 @@ ssl:
- "yourdomain.com"
#END
```
+
+### 配置 global rule
+
+```yaml
+global_rules:
+ -
+ id: 1
+ plugins:
+ response-rewrite:
+ body: "hello\n"
+```
+
+### 配置 consumer
+
+```yaml
+consumers:
+ - username: jwt
+ plugins:
+ jwt-auth:
+ key: user-key
+ secret: my-secret-key
+```
+
+### 配置 plugin metadata
+
+```yaml
+upstreams:
+ - id: 1
+ nodes:
+ "127.0.0.1:1980": 1
+ type: roundrobin
+routes:
+ -
+ uri: /hello
+ upstream_id: 1
+ plugins:
+ http-logger:
+ batch_max_size: 1
+ uri: http://127.0.0.1:1980/log
+plugin_metadata:
+ - id: http-logger # 注意 id 是插件名称
+ log_format:
+ host: "$host",
+ remote_addr: "$remote_addr"
+```
+
+### 配置 stream route
+
+```yaml
+stream_routes:
+ - server_addr: 127.0.0.1
+ server_port: 1985
+ id: 1
+ upstream_id: 1
+ plugins:
+ mqtt-proxy:
+ protocol_name: "MQTT"
+ protocol_level: 4
+ upstream:
+ ip: "127.0.0.1"
+ port: 1995
+upstreams:
+ - nodes:
+ "127.0.0.1:1995": 1
+ type: roundrobin
+ id: 1
+```
diff --git a/t/config-center-yaml/stream-route.t
b/t/config-center-yaml/plugin-metadata.t
similarity index 54%
copy from t/config-center-yaml/stream-route.t
copy to t/config-center-yaml/plugin-metadata.t
index 77d2dd9..0ad0c6c 100644
--- a/t/config-center-yaml/stream-route.t
+++ b/t/config-center-yaml/plugin-metadata.t
@@ -33,14 +33,8 @@ _EOC_
$block->set_value("yaml_config", $yaml_config);
- $block->set_value("stream_enable", 1);
-
- if (!$block->stream_request) {
- $block->set_value("stream_request", "mmm");
- }
-
- if (!$block->error_log && !$block->no_error_log) {
- $block->set_value("no_error_log", "[error]\n[alert]");
+ if (!$block->no_error_log) {
+ $block->set_value("no_error_log", "[error]");
}
});
@@ -50,52 +44,26 @@ __DATA__
=== TEST 1: sanity
--- apisix_yaml
-stream_routes:
- - server_addr: 127.0.0.1
- server_port: 1985
- id: 1
- upstream:
- nodes:
- "127.0.0.1:1995": 1
- type: roundrobin
-#END
---- stream_response
-hello world
-
-
-
-=== TEST 2: rule with bad plugin
---- apisix_yaml
-stream_routes:
- - server_addr: 127.0.0.1
- server_port: 1985
- id: 1
- plugins:
- mqtt-proxy:
- uri: 1
- upstream:
- nodes:
- "127.0.0.1:1995": 1
- type: roundrobin
-#END
---- error_log eval
-qr/property "\w+" is required/
-
-
-
-=== TEST 3: ignore unknown plugin
---- apisix_yaml
-stream_routes:
- - server_addr: 127.0.0.1
- server_port: 1985
- id: 1
+upstreams:
+ - id: 1
+ nodes:
+ "127.0.0.1:1980": 1
+ type: roundrobin
+routes:
+ -
+ uri: /hello
+ upstream_id: 1
plugins:
- x-rewrite:
- uri: 1
- upstream:
- nodes:
- "127.0.0.1:1995": 1
- type: roundrobin
+ http-logger:
+ batch_max_size: 1
+ uri: http://127.0.0.1:1980/log
+plugin_metadata:
+ - id: http-logger
+ log_format:
+ host: "$host",
+ remote_addr: "$remote_addr"
#END
---- stream_response
-hello world
+--- request
+GET /hello
+--- error_log
+"remote_addr":"127.0.0.1"
diff --git a/t/config-center-yaml/stream-route.t
b/t/config-center-yaml/stream-route.t
index 77d2dd9..b6bfabf 100644
--- a/t/config-center-yaml/stream-route.t
+++ b/t/config-center-yaml/stream-route.t
@@ -99,3 +99,30 @@ stream_routes:
#END
--- stream_response
hello world
+
+
+
+=== TEST 4: sanity with plugin
+--- apisix_yaml
+stream_routes:
+ - server_addr: 127.0.0.1
+ server_port: 1985
+ id: 1
+ upstream_id: 1
+ plugins:
+ mqtt-proxy:
+ protocol_name: "MQTT"
+ protocol_level: 4
+ upstream:
+ ip: "127.0.0.1"
+ port: 1995
+upstreams:
+ - nodes:
+ "127.0.0.1:1995": 1
+ type: roundrobin
+ id: 1
+#END
+--- stream_request eval
+"\x10\x0f\x00\x04\x4d\x51\x54\x54\x04\x02\x00\x3c\x00\x03\x66\x6f\x6f"
+--- stream_response
+hello world