Sn0rt commented on issue #9661:
URL: https://github.com/apache/apisix/issues/9661#issuecomment-1628605187
install redis
```bash
$ sudo apt install redis
100 [09:23:03]
[sudo] password for guohao:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
redis is already the newest version (5:6.0.16-1ubuntu1).
The following package was automatically installed and is no longer required:
openjdk-11-jre
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
```
enable stream proxy
```diff
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index e40dc174..3d8dd4c4 100755
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -73,15 +73,15 @@ apisix:
# radixtree_uri_with_parameter: similar to
radixtree_uri but match URI with parameters. See
https://github.com/api7/lua-resty-radixtree/#parameters-in-path for more
details.
ssl: radixtree_sni # radixtree_sni: match route by SNI
- # stream_proxy: # TCP/UDP L4 proxy
- # only: true # Enable L4 proxy only without L7 proxy.
- # tcp:
- # - addr: 9100 # Set the TCP proxy listening ports.
- # tls: true
- # - addr: "127.0.0.1:9101"
- # udp: # Set the UDP proxy listening ports.
- # - 9200
- # - "127.0.0.1:9201"
+ stream_proxy: # TCP/UDP L4 proxy
+ only: true # Enable L4 proxy only without L7 proxy.
+ tcp:
+ - addr: 9100 # Set the TCP proxy listening ports.
+ tls: true
+ - addr: "127.0.0.1:9101"
+ udp: # Set the UDP proxy listening ports.
+ - 9200
+ - "127.0.0.1:9201"
# dns_resolver: # If not set, read from `/etc/resolv.conf`
# - 1.1.1.1
@@ -141,7 +141,7 @@ nginx_config: # Config for render
the template to generate n
# user: root # Set the execution user of the worker
process. This is only
# effective if the master process runs
with super-user privileges.
error_log: logs/error.log # Location of the error log.
- error_log_level: warn # Logging level: info, debug, notice,
warn, error, crit, alert, or emerg.
+ error_log_level: debug # Logging level: info, debug, notice,
warn, error, crit, alert, or emerg.
worker_processes: auto # Automatically determine the optimal
number of worker processes based
```
set the router
```bash
curl http://127.0.0.1:9180/apisix/admin/stream_routes/1 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"limit-conn": {
"conn": 1,
"burst": 0,
"default_conn_delay": 0.1,
"rejected_code": 503,
"key_type": "var",
"key": "remote_addr"
}
},
"upstream": {
"type": "none",
"nodes": {
"127.0.0.1:6379": 1
}
}
}
'
```
reload the APISIX instance
```bash
$ make reload
[09:24:37]
[ info ] reload -> [ Start ]
/home/guohao/apisix/bin/apisix reload
/usr/local/openresty//luajit/bin/luajit ./apisix/cli/apisix.lua reload
Warning! Current maximum number of open file descriptors [1024] is not
greater than 1024, please increase user limits by execute 'ulimit -n <new user
limits>' , otherwise the performance is low.
[ info ] reload -> [ Done ]
```
test the stream proxy
```bash
$ redis-cli -h localhost -p 9101
[09:24:53]
localhost:9101> set key test
OK
localhost:9101> get key
"test"
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]