superwjc opened a new issue #5138: URL: https://github.com/apache/apisix/issues/5138
### Issue description I have apisix-0.4.0 and apisix-ingress-controller-0.7.0 installed from local ".tgz" with helm, with the "stream_proxy" enabled, as described at [https://apisix.apache.org/docs/apisix/stream-proxy](url). Setting upstreams and routes with api was as intend, but setting stream_routes returns "400 Bad Request". ### Environment - apisix version (cmd: `apisix version`): ``` kubectl -n apisix \ exec -it $(kubectl -n apisix \ get pod -l "app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix" | \ sed -n '1!p' | awk '{print $1}' | sed -n '1p') \ -- apisix version ``` ``` Defaulted container "apisix" out of: apisix, wait-etcd (init) /usr/local/openresty/luajit/bin/luajit ./apisix/cli/apisix.lua version 2.7 ``` - OS (cmd: `uname -a`): ``` uname -a ``` ``` Linux k8s-master-2 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ``` - OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`): ``` kubectl -n apisix \ exec -it $(kubectl -n apisix \ get pod -l "app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix" | \ sed -n '1!p' | awk '{print $1}' | sed -n '1p') \ -- nginx -V ``` ``` Defaulted container "apisix" out of: apisix, wait-etcd (init) nginx version: openresty/1.19.3.1 built by gcc 10.2.1 20201203 (Alpine 10.2.1_pre1) built with OpenSSL 1.1.1k 25 Mar 2021 TLS SNI support enabled configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.19 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.9 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/pcre/l ib -L/usr/local/openresty/openssl/lib -Wl,-rpath,/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl/lib' --with-pcre --with-compat --with-file-aio --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_module=dynamic --with-ipv6 --with-mail --with-mail_ssl_module --with-md5-asm --with-pcre-jit --with-sha1-asm --with-stream --with-stream_ssl_module --with-threads --with-stream --with-stream_ssl_preread_module ``` - etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API): ``` kubectl exec -it -n apisix apisix-etcd-0 -- etcdctl version ``` ``` etcdctl version: 3.4.16 API version: 3.4 ``` - apisix-dashboard version, if have: - the plugin runner version, if the issue is about a plugin runner (cmd: depended on the kind of runner): - luarocks version, if the issue is about installation (cmd: `luarocks --version`): ``` kubectl -n apisix \ exec -it $(kubectl -n apisix \ get pod -l "app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix" | \ sed -n '1!p' | awk '{print $1}' | sed -n '1p') \ -- luarocks --version ``` ``` Defaulted container "apisix" out of: apisix, wait-etcd (init) /usr/local/openresty/luajit/bin/luarocks 3.7.0 LuaRocks main command-line interface ``` ### Steps to reproduce **1. run helm install in dry-run and debug mode with the following settings:** ``` helm -n apisix install apisix apisix-0.4.0.tgz \ --create-namespace \ --set admin.allow.ipList="{0.0.0.0/0}" \ --set etcd.persistence.enabled=false \ --set apisix.stream_proxy.only=false \ --set apisix.stream_proxy.tcp[0].addr=9100 \ --set apisix.stream_proxy.tcp[0].tls=true \ --set apisix.stream_proxy.udp[0].addr=9200 \ --debug \ --dry-run ``` **the output contains the following snippet:** ``` ... USER-SUPPLIED VALUES: ... apisix: stream_proxy: only: false tcp: - addr: 9100 tls: true udp: - addr: 9200 ... ... COMPUTED VALUES: ... apisix: ... stream_proxy: only: false tcp: - addr: 9100 tls: true udp: - addr: 9200 ``` **2. install apisix and apisix-ingress-controller:** ``` helm -n apisix install apisix apisix-0.4.0.tgz \ --create-namespace \ --set admin.allow.ipList="{0.0.0.0/0}" \ --set etcd.persistence.enabled=false \ --set apisix.stream_proxy.only=false \ --set apisix.stream_proxy.tcp[0].addr=9100 \ --set apisix.stream_proxy.tcp[0].tls=true \ --set apisix.stream_proxy.udp[0].addr=9200 ``` ``` helm -n apisix \ install apisix-ingress-controller apisix-ingress-controller-0.7.0.tgz \ --create-namespace ``` **all pods and services were ok, the admin address was 10.96.107.57:9180** ``` # kubectl -n apisix get pod,svc NAME READY STATUS RESTARTS AGE pod/apisix-7d65976d76-29lqv 1/1 Running 0 3m51s pod/apisix-etcd-0 1/1 Running 0 3m51s pod/apisix-etcd-1 1/1 Running 0 3m51s pod/apisix-etcd-2 1/1 Running 0 3m51s pod/apisix-ingress-controller-698c9cc86-phgqg 1/1 Running 0 65s NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/apisix-admin ClusterIP 10.96.107.57 <none> 9180/TCP 3m52s service/apisix-etcd ClusterIP 10.111.26.88 <none> 2379/TCP,2380/TCP 3m52s service/apisix-etcd-headless ClusterIP None <none> 2379/TCP,2380/TCP 3m52s service/apisix-gateway NodePort 10.111.3.230 <none> 80:32285/TCP 3m52s service/apisix-ingress-controller ClusterIP 10.110.66.223 <none> 80/TCP 65s ``` **3. get the admin-key of the apisix pod:** ``` kubectl -n apisix \ exec -it $(kubectl -n apisix \ get pod -l "app.kubernetes.io/instance=apisix,app.kubernetes.io/name=apisix" | \ sed -n '1!p' | awk '{print $1}' | sed -n '1p') \ -- cat conf/config.yaml 2>/dev/null | \ grep '^\s*key: ' | sed -n '1p' | awk '{print $2}' ``` ``` edd1c9f034335f136f87ad84b625c8f1 ``` **4. set a route for test, no errors occured:** ``` curl -sS http://10.96.107.57:9180/apisix/admin/upstreams/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "nodes": { "default.webserver:80": 100 }, "type": "roundrobin", "scheme": "http" }' ``` ``` {"action":"set","node":{"value":{"update_time":1632640526,"type":"roundrobin","hash_on":"vars","create_time":1632640526,"pass_host":"pass","nodes":{"default.webserver:80":100},"scheme":"http","id":"1"},"key":"\/apisix\/upstreams\/1"}} ``` ``` curl -sS http://10.96.107.57:9180/apisix/admin/upstreams -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET | jq ``` ``` { "node": { "dir": true, "nodes": [ { "modifiedIndex": 13, "value": { "id": "1", "create_time": 1632640526, "update_time": 1632640526, "type": "roundrobin", "pass_host": "pass", "nodes": { "default.webserver:80": 100 }, "hash_on": "vars", "scheme": "http" }, "key": "/apisix/upstreams/1", "createdIndex": 13 } ], "key": "/apisix/upstreams" }, "action": "get", "count": 1 } ``` **5. set a stream route fully copied from [https://apisix.apache.org/docs/apisix/stream-proxy](url), returned the "400 Bad Request" massage:** ``` curl -sS http://10.96.107.57:9180/apisix/admin/stream_routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d ' { "remote_addr": "127.0.0.1", "upstream": { "nodes": { "127.0.0.1:1995": 1 }, "type": "roundrobin" } }' ``` ``` HTTP/1.1 400 Bad Request Server: openresty Date: Sun, 26 Sep 2021 07:22:27 GMT Content-Type: text/html; charset=utf-8 Content-Length: 154 Connection: close Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Expose-Headers: * Access-Control-Max-Age: 3600 <html> <head><title>400 Bad Request</title></head> <body> <center><h1>400 Bad Request</h1></center> <hr><center>openresty</center> </body> </html> ``` ``` curl -sS http://10.96.107.57:9180/apisix/admin/stream_routes -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X GET | jq ``` ``` { "node": { "dir": true, "nodes": {}, "key": "/apisix/stream_routes" }, "action": "get", "count": 0 } ``` ### Actual result described above ### Error log described above ### Expected result Adding stream routes with api should behave the same as described at the official documents [https://apisix.apache.org/docs/apisix/stream-proxy](url) -- 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]
