Skip to content

Commit

Permalink
Merge branch 'master' into mtc1
Browse files Browse the repository at this point in the history
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
  • Loading branch information
spacewander committed Jul 4, 2022
2 parents cb0af9d + bdf71ae commit 34e03e0
Show file tree
Hide file tree
Showing 24 changed files with 219 additions and 125 deletions.
17 changes: 12 additions & 5 deletions apisix/cli/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,18 @@ function _M.read_yaml_conf(apisix_home)
end
end

if default_conf.deployment
and default_conf.deployment.role == "traditional"
and default_conf.deployment.etcd
then
default_conf.etcd = default_conf.deployment.etcd
if default_conf.deployment then
if default_conf.deployment.role == "traditional" then
default_conf.etcd = default_conf.deployment.etcd

elseif default_conf.deployment.role == "control_plane" then
default_conf.etcd = default_conf.deployment.etcd
default_conf.apisix.enable_admin = true

elseif default_conf.deployment.role == "data_plane" then
default_conf.etcd = default_conf.deployment.role_data_plane.control_plane
default_conf.apisix.enable_admin = false
end
end

return default_conf
Expand Down
8 changes: 2 additions & 6 deletions apisix/core/etcd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,10 @@ local function new()
return nil, nil, err
end

local etcd_conf
local etcd_conf = clone_tab(local_conf.etcd)
local proxy_by_conf_server = false

if local_conf.deployment then
etcd_conf = clone_tab(local_conf.deployment.etcd)

if local_conf.deployment.role == "traditional"
-- we proxy the etcd requests in traditional mode so we can test the CP's behavior in
-- daily development. However, a stream proxy can't be the CP.
Expand All @@ -65,8 +63,6 @@ local function new()
-- TODO: add the proxy conf in control_plane
proxy_by_conf_server = true
end
else
etcd_conf = clone_tab(local_conf.etcd)
end

local prefix = etcd_conf.prefix
Expand Down Expand Up @@ -417,7 +413,7 @@ end
-- -- etcdserver = "3.5.0"
-- -- }
function _M.server_version()
local etcd_cli, err = new()
local etcd_cli, _, err = new()
if not etcd_cli then
return nil, err
end
Expand Down
2 changes: 1 addition & 1 deletion conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ etcd:
#password: 5tHkHhYkjr6cQY # root password for etcd
tls:
# To enable etcd client certificate you need to build APISIX-Base, see
# https://apisix.apache.org/docs/apisix/FAQ#how-do-i-build-the-apisix-base-environment?
# https://apisix.apache.org/docs/apisix/FAQ#how-do-i-build-the-apisix-base-environment
#cert: /path/to/cert # path of certificate used by the etcd client
#key: /path/to/key # path of key used by the etcd client

Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/admin-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ The following should be considered when setting the `hash_on` value:
- When set to `vars_combinations`, the `key` is required. The value of the key can be a combination of any of the [Nginx variables](http://nginx.org/en/docs/varindex.html) like `$request_uri$remote_addr`.
- When no value is set for either `hash_on` or `key`, the key defaults to `remote_addr`.

The features described below requires APISIX to be run on [APISIX-Base](./FAQ.md#how-do-i-build-the-apisix-base-environment?):
The features described below requires APISIX to be run on [APISIX-Base](./FAQ.md#how-do-i-build-the-apisix-base-environment):

You can set the `scheme` to `tls`, which means "TLS over TCP".

Expand Down
32 changes: 0 additions & 32 deletions docs/en/latest/architecture-design/apisix.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,3 @@ title: APISIX
## Plugin Hierarchy Structure

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

## Configuring APISIX

Apache APISIX can be configured in two ways:

1. By directly changing `conf/config.yaml`.
2. Using the `--config` or the `-c` flag to pass in the file path of your config file while starting APISIX (`apisix start -c <path to config file>`).

Configurations can be added to this YAML file and Apache APISIX will fall back to the default configurations for anything that is not configured in this file.

For example, to set the default listening port to 8000 while keeping other configurations as default, your configuration file (`config.yaml`) would look like:

```yaml
apisix:
node_listen: 8000 # APISIX listening port
```
Similarly, to set the listening port to 8000 and set the etcd address to `http://foo:2379` while keeping other configurations as default, your configuration file would look like:

```yaml
apisix:
node_listen: 8000 # APISIX listening port
etcd:
host: "http://foo:2379" # etcd address
```

Default configurations of APISIX can be found in the `conf/config-default.yaml` file.

**Note**: This file is bound to the APISIX source code and should **NOT** be modified. The configuration should only be changed by the methods mentioned above.

**Note**: The `conf/nginx.conf` file is automatically generated by APISIX and should **NOT** be edited.
2 changes: 1 addition & 1 deletion docs/en/latest/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
},
{
"type": "category",
"label": "Other Protocols",
"label": "Other protocols",
"items": [
"plugins/dubbo-proxy",
"plugins/mqtt-proxy",
Expand Down
49 changes: 49 additions & 0 deletions docs/en/latest/installation-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ APISIX can be installed by the different methods listed below:
{label: 'Docker', value: 'docker'},
{label: 'Helm', value: 'helm'},
{label: 'RPM', value: 'rpm'},
{label: 'Source Code', value: 'source code'},
]}>
<TabItem value="docker">

Expand Down Expand Up @@ -166,6 +167,12 @@ Run `apisix help` to get a list of all available operations.

:::

</TabItem>

<TabItem value="source code">

If you want to build APISIX from source, please refer to [Building APISIX from source](./building-apisix.md).

</TabItem>
</Tabs>

Expand Down Expand Up @@ -207,6 +214,48 @@ brew services start etcd

## Next steps

### Configuring APISIX

You can configure your APISIX deployment in two ways:

1. By directly changing your configuration file (`conf/config.yaml`).
2. By using the `--config` or the `-c` flag to pass the path to your configuration file while starting APISIX.

```shell
apisix start -c <path to config file>
```

APISIX will use the configurations added in this configuration file and will fall back to the default configuration if anything is not configured.

For example, to configure the default listening port to be `8000` without changing other configurations, your configuration file could look like this:

```yaml title="conf/config.yaml"
apisix:
node_listen: 8000
```

Now, if you decide you want to change the etcd address to `http://foo:2379`, you can add it to your configuration file. This will not change other configurations.

```yaml title="conf/config.yaml"
apisix:
node_listen: 8000
etcd:
host: "http://foo:2379"
```

:::warning

APISIX's default configuration can be found in `conf/config-default.yaml` file and it should not be modified. It is bound to the source code and the configuration should only be changed by the methods mentioned above.
:::
:::warning
The `conf/nginx.conf` file is automatically generated and should not be modified.
:::
### Updating Admin API key
It is recommended to modify the Admin API key to ensure security.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/latest/mtls.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ curl --cacert /data/certs/mtls_ca.crt --key /data/certs/mtls_client.key --cert /

### How to configure

You need to build [APISIX-Base](./FAQ.md#how-do-i-build-the-apisix-base-environment?) and configure `etcd.tls` section if you want APISIX to work on an etcd cluster with mTLS enabled.
You need to build [APISIX-Base](./FAQ.md#how-do-i-build-the-apisix-base-environment) and configure `etcd.tls` section if you want APISIX to work on an etcd cluster with mTLS enabled.

```yaml
etcd:
Expand Down
85 changes: 41 additions & 44 deletions docs/en/latest/plugins/dubbo-proxy.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
---
title: dubbo-proxy
keywords:
- APISIX
- API Gateway
- Plugin
- Apache Dubbo
- dubbo-proxy
description: This document contains information about the Apache APISIX dubbo-proxy Plugin.
---

<!--
Expand All @@ -23,40 +30,39 @@ title: dubbo-proxy

## Description

dubbo-proxy plugin allows you proxy HTTP request to [**dubbo**](http://dubbo.apache.org).
The `dubbo-proxy` Plugin allows you to proxy HTTP requests to [Apache Dubbo](https://dubbo.apache.org/en/index.html).

:::info IMPORTANT

## Requirement
If you are using OpenResty, you need to build it with Dubbo support. See [How do I build the APISIX base environment](./../FAQ.md#how-do-i-build-the-apisix-base-environment) for details.

If you are using OpenResty, you need to build it with dubbo support, see [APISIX-Base](./FAQ/#how-do-i-build-the-apisix-base-environment).
:::

## Runtime Attributes

| Name | Type | Requirement | Default | Valid | Description |
| ------------ | ------ | ----------- | -------- | ------------ | -------------------------------------------------------------------- |
| service_name | string | required | | | dubbo provider service name|
| service_version | string | required | | | dubbo provider service version|
| method | string | optional | the path of uri | | dubbo provider service method|
| Name | Type | Required | Default | Description |
| --------------- | ------ | -------- | -------------------- | ------------------------------- |
| service_name | string | True | | Dubbo provider service name. |
| service_version | string | True | | Dubbo provider service version. |
| method | string | False | The path of the URI. | Dubbo provider service method. |

## Static Attributes

| Name | Type | Requirement | Default | Valid | Description |
| ------------ | ------ | ----------- | -------- | ------------ | -------------------------------------------------------------------- |
| upstream_multiplex_count | number | required | 32 | >= 1 | the maximum number of multiplex requests in an upstream connection |
| Name | Type | Required | Default | Valid values | Description |
| ------------------------ | ------ | -------- | ------- | ------------ | --------------------------------------------------------------- |
| upstream_multiplex_count | number | True | 32 | >= 1 | Maximum number of multiplex requests in an upstream connection. |

## How To Enable
## Enabling the Plugin

First of all, enable the dubbo-proxy plugin in the `config.yaml`:
To enable the `dubbo-proxy` Plugin, you have to add it in your configuration file (`conf/config.yaml`):

```
# Add this in config.yaml
```yaml title="conf/config.yaml"
plugins:
- ... # plugin you need
- ...
- dubbo-proxy
```
Then reload APISIX.

Here's an example, enable the dubbo-proxy plugin on the specified route:
Now, when APISIX is reloaded, you can add it to a specific Route as shown below:
```shell
curl http://127.0.0.1:9080/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
Expand All @@ -83,44 +89,41 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f1
}'
```

## Test Plugin
## Example usage

You can follow the [Quick Start](https://github.com/alibaba/tengine/tree/master/modules/mod_dubbo#quick-start) example in Tengine and use the configuration above to test it.
They should provide the same result.
You can follow the [Quick Start](https://github.com/alibaba/tengine/tree/master/modules/mod_dubbo#quick-start) guide in Tengine with the configuration above for testing.

The returned data from upstream dubbo service must be a `Map<String, String>`.
Dubbo returns data in the form `Map<String, String>`.

If the returned data is
If the returned data is:

```json
{
"status": "200",
"header1": "value1",
"header2": "valu2",
"body": "blahblah"
"status": "200",
"header1": "value1",
"header2": "value2",
"body": "body of the message"
}
```

the converted HTTP response will be
The converted HTTP response will be:

```
HTTP/1.1 200 OK # "status" will be the status code
HTTP/1.1 200 OK
...
header1: value1
header2: value2
...
blahblah # "body" will be the body
body of the message
```

## Disable Plugin

When you want to disable the dubbo-proxy plugin on a route/service, 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:
To disable the `dubbo-proxy` Plugin, you can delete the corresponding JSON configuration from the Plugin configuration. APISIX will automatically reload and you do not have to restart for this to take effect.

```shell
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uris": [
Expand All @@ -133,15 +136,9 @@ $ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335
}'
```

The dubbo-proxy plugin has been disabled now. It works for other plugins.

If you want to disable dubbo-proxy plugin totally,
you need to comment out in the `config.yaml`:
To completely disable the `dubbo-proxy` Plugin, you can remove it from your configuration file (`conf/config.yaml`):

```yaml
```yaml title="conf/config.yaml"
plugins:
- ... # plugin you need
#- dubbo-proxy
# - dubbo-proxy
```

And then reload APISIX.
2 changes: 1 addition & 1 deletion docs/en/latest/plugins/gzip.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The `gzip` Plugin dynamically sets the behavior of [gzip in Nginx](https://docs.

:::info IMPORTANT

This Plugin requires APISIX to run on [APISIX-Base](../FAQ.md#how-do-i-build-the-apisix-base-environment?).
This Plugin requires APISIX to run on [APISIX-Base](../FAQ.md#how-do-i-build-the-apisix-base-environment).

:::

Expand Down
Loading

0 comments on commit 34e03e0

Please sign in to comment.