You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2021/03/31 00:59:26 UTC

[apisix] branch master updated: docs: add chinese version of dubbo-proxy.md (#3938)

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 4c8f0f4  docs: add chinese version of dubbo-proxy.md (#3938)
4c8f0f4 is described below

commit 4c8f0f4a63808619af9cde70cb119b8257db52f3
Author: super_mario <40...@qq.com>
AuthorDate: Wed Mar 31 08:59:15 2021 +0800

    docs: add chinese version of dubbo-proxy.md (#3938)
---
 docs/zh/latest/README.md              |   2 +-
 docs/zh/latest/plugins/dubbo-proxy.md | 157 ++++++++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+), 1 deletion(-)

diff --git a/docs/zh/latest/README.md b/docs/zh/latest/README.md
index 73445c7..bf04584 100644
--- a/docs/zh/latest/README.md
+++ b/docs/zh/latest/README.md
@@ -66,7 +66,7 @@ A/B 测试、金丝雀发布(灰度发布)、蓝绿部署、限流限速、抵
 - **多协议**
 
   - [TCP/UDP 代理](stream-proxy.md): 动态 TCP/UDP 代理。
-  - [Dubbo 代理](../../en/latest/plugins/dubbo-proxy.md): 动态代理 HTTP 请求到 Dubbo 后端。
+  - [Dubbo 代理](plugins/dubbo-proxy.md): 动态代理 HTTP 请求到 Dubbo 后端。
   - [动态 MQTT 代理](plugins/mqtt-proxy.md): 支持用 `client_id` 对 MQTT 进行负载均衡,同时支持 MQTT [3.1.\*](http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html) 和 [5.0](https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.html) 两个协议标准。
   - [gRPC 代理](grpc-proxy.md):通过 APISIX 代理 gRPC 连接,并使用 APISIX 的大部分特性管理你的 gRPC 服务。
   - [gRPC 协议转换](plugins/grpc-transcode.md):支持协议的转换,这样客户端可以通过 HTTP/JSON 来访问你的 gRPC API。
diff --git a/docs/zh/latest/plugins/dubbo-proxy.md b/docs/zh/latest/plugins/dubbo-proxy.md
new file mode 100644
index 0000000..6de275f
--- /dev/null
+++ b/docs/zh/latest/plugins/dubbo-proxy.md
@@ -0,0 +1,157 @@
+---
+title: dubbo-proxy
+---
+
+<!--
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+-->
+
+## 摘要
+
+- [**简介**](#简介)
+- [**要求**](#要求)
+- [**运行时属性**](#运行时属性)
+- [**静态属性**](#静态属性)
+- [**如何启用**](#如何启用)
+- [**测试插件**](#测试插件)
+- [**禁用插件**](#禁用插件)
+
+## 简介
+
+`dubbo-proxy` 插件允许将 `HTTP` 请求代理到 [**dubbo**](http://dubbo.apache.org)。
+
+## 要求
+
+如果你正在使用 `OpenResty`, 你需要编译它来支持 `dubbo`, 参考 [如何编译](../how-to-build.md#6-build-openresty-for-apisix)。
+在 `APISIX` 中为了实现使从 `http` 代理到 `dubbo`,我们在`Tengine` 的 `mod_dubbo` 基础上对 `dubbo` 模块做了改进。 所有的修改已经提交给 `Tengine`,但是还未合并到最新的 `release` 版本中(Tengine-2.3.2) 。所以目前 `Tengine` 自身是不支持此特性的。
+
+## 运行时属性
+
+| 名称       | 类型 | 必选项 | 默认值  | 有效值       | 描述                                                          |
+| ------------ | ------ | ----------- | -------- | ------------ | -------------------------------------------------------------------- |
+| service_name    | string | 必选  |          |              | dubbo 服务名字 |
+| service_version | string | 必选    |          |              | dubbo 服务版本 |
+| method          | string | 可选    | uri路径 |     | dubbo 服务方法 |
+
+## 静态属性
+
+| 名称       | 类型   | 必选项 | 默认值 | 有效值        | 描述                                                        |
+| ------------ | ------ | ----------- | -------- | ------------ | -------------------------------------------------------------------- |
+| upstream_multiplex_count | number | 必选    | 32        | >= 1 | 上游连接中最大的多路复用请求数 |
+
+## 如何启用
+
+首先,在 `config.yaml` 中启用 `dubbo-proxy` 插件:
+
+```
+# Add this in config.yaml
+plugins:
+  - ... # plugin you need
+  - dubbo-proxy
+```
+
+然后重载 `APISIX`。
+
+这里有个例子,在指定的路由中启用 `dubbo-proxy` 插件:
+
+```shell
+curl http://127.0.0.1:9080/apisix/admin/upstream/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "nodes": {
+        "127.0.0.1:20880": 1
+    },
+    "type": "roundrobin"
+}'
+
+curl http://127.0.0.1:9080/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
+{
+    "uris": [
+        "/hello"
+    ],
+    "plugins": {
+        "dubbo-proxy": {
+            "service_name": "org.apache.dubbo.sample.tengine.DemoService",
+            "service_version": "0.0.0",
+            "method": "tengineDubbo"
+        }
+    },
+    "upstream_id": 1
+}'
+```
+
+## 测试插件
+
+你可以在 `Tengine` 提供的 [快速开始](https://github.com/alibaba/tengine/tree/master/modules/mod_dubbo#quick-start) 例子中使用上述配置进行测试。
+
+将会有同样的结果。
+
+从上游 `dubbo` 服务返回的数据一定是`Map<String, String>` 类型。
+
+如果返回的数据如下
+
+```json
+{
+    "status": "200",
+    "header1": "value1",
+    "header2": "valu2",
+    "body": "blahblah"
+}
+```
+
+则对应的 `HTTP` 响应如下
+
+```http
+HTTP/1.1 200 OK # "status" will be the status code
+...
+header1: value1
+header2: value2
+...
+
+blahblah # "body" will be the body
+```
+
+## 禁用插件
+
+当你想在某个路由或服务中禁用 `dubbo-proxy` 插件,非常简单,你可以直接删除插件配置中的 `json` 配置,不需要重启服务就能立即生效:
+
+```shell
+$ curl http://127.0.0.1:2379/v2/keys/apisix/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d value='
+{
+    "methods": ["GET"],
+    "uris": [
+        "/hello"
+    ],
+    "plugins": {
+    },
+    "upstream_id": 1
+    }
+}'
+```
+
+现在 `dubbo-proxy` 插件就已经被禁用了。 此方法同样适用于其他插件。
+
+如果你想彻底禁用 `dubbo-proxy` 插件,
+你需要在 `config.yaml` 中注释掉以下内容:
+
+```yaml
+plugins:
+  - ... # plugin you need
+  #- dubbo-proxy
+```
+
+然后重新加载 `APISIX`。