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

change: enable HTTP when stream proxy is set and enable_admin is true #5867

Merged
merged 2 commits into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ stream {
}
{% end %}

{% if not (stream_proxy and stream_proxy.only ~= false) then %}
{% if enable_admin or not (stream_proxy and stream_proxy.only ~= false) then %}
http {
# put extra_lua_path in front of the builtin path
# so user can override the source code
Expand Down
5 changes: 4 additions & 1 deletion docs/en/latest/stream-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@ apisix:
- "127.0.0.1:9211"
```

If you need to enable both HTTP and stream proxy, set the `only` to false:
If `apisix.enable_admin` is true, both HTTP and stream proxy are enabled with the configuration above.

If you have set the `enable_admin` to false, and need to enable both HTTP and stream proxy, set the `only` to false:

```yaml
apisix:
enable_admin: false
stream_proxy: # TCP/UDP proxy
only: false
tcp: # TCP proxy address list
Expand Down
5 changes: 4 additions & 1 deletion docs/zh/latest/stream-proxy.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ apisix:
- "127.0.0.1:9211"
```

如果你需要同时启用 HTTP 和 stream 代理,设置 `only` 为 false:
如果 `apisix.enable_admin` 为 true,上面的配置会同时启用 HTTP 和 stream 代理。

如果你设置 `enable_admin` 为 false,且需要同时启用 HTTP 和 stream 代理,设置 `only` 为 false:

```yaml
apisix:
enable_admin: false
stream_proxy: # TCP/UDP proxy
only: false
tcp: # TCP proxy address list
Expand Down
4 changes: 2 additions & 2 deletions t/cli/test_core_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ nginx_config:
make init

count=$(grep -c "lua_max_pending_timers 10240;" conf/nginx.conf)
if [ "$count" -ne 1 ]; then
if [ "$count" -ne 2 ]; then
echo "failed: failed to set lua_max_pending_timers in stream proxy"
exit 1
fi

echo "passed: set lua_max_pending_timers successfully in stream proxy"

count=$(grep -c "lua_max_running_timers 2561;" conf/nginx.conf)
if [ "$count" -ne 1 ]; then
if [ "$count" -ne 2 ]; then
echo "failed: failed to set lua_max_running_timers in stream proxy"
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions t/cli/test_dns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ apisix:
make init

count=$(grep -c "resolver 127.0.0.1 \[::1\]:5353 valid=30;" conf/nginx.conf)
if [ "$count" -ne 1 ]; then
if [ "$count" -ne 2 ]; then
echo "failed: dns_resolver_valid doesn't take effect"
exit 1
fi
Expand All @@ -74,7 +74,7 @@ apisix:
make init

count=$(grep -c "resolver 127.0.0.1 \[::1\] \[::2\];" conf/nginx.conf)
if [ "$count" -ne 1 ]; then
if [ "$count" -ne 2 ]; then
echo "failed: can't handle IPv6 resolver w/o bracket"
exit 1
fi
Expand Down
18 changes: 18 additions & 0 deletions t/cli/test_stream_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

echo "
apisix:
enable_admin: false
stream_proxy:
tcp:
- addr: 9100
Expand All @@ -38,6 +39,7 @@ echo "passed: enable stream proxy only by default"

echo "
apisix:
enable_admin: false
stream_proxy:
only: false
tcp:
Expand All @@ -52,6 +54,22 @@ if [ "$count" -ne 2 ]; then
exit 1
fi

echo "
apisix:
enable_admin: true
stream_proxy:
tcp:
- addr: 9100
" > conf/config.yaml

make init

count=$(grep -c "lua_package_path" conf/nginx.conf)
if [ "$count" -ne 2 ]; then
echo "failed: failed to enable stream proxy and http proxy when admin is enabled"
exit 1
fi

echo "passed: enable stream proxy and http proxy"

echo "
Expand Down