From d60428c4c7b0a33e9fc16d1d3a9567d58372ea90 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 13:52:06 +0800 Subject: [PATCH 01/31] chore: upgrade openresty-1.25.3.1 --- ci/centos7-ci.sh | 5 +---- ci/common.sh | 8 ++++++++ ci/linux-install-openresty.sh | 5 +---- ci/redhat-ci.sh | 6 ++---- utils/install-dependencies.sh | 3 ++- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ci/centos7-ci.sh b/ci/centos7-ci.sh index 344552e9f4ef..66417ebf5cb1 100755 --- a/ci/centos7-ci.sh +++ b/ci/centos7-ci.sh @@ -44,10 +44,7 @@ install_dependencies() { yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo yum install -y openresty-pcre-devel openresty-zlib-devel - export runtime_version=${APISIX_RUNTIME} - wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - chmod +x build-apisix-runtime.sh - ./build-apisix-runtime.sh latest + install_apisix_runtime() curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf diff --git a/ci/common.sh b/ci/common.sh index 9aa132af1c06..eded1e57753d 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -75,6 +75,14 @@ install_curl () { curl -V } +intall_apisix_runtime() { + export runtime_version=${APISIX_RUNTIME} + # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" + chmod +x build-apisix-runtime.sh + ./build-apisix-runtime.sh latest +} + install_grpcurl () { # For more versions, visit https://github.com/fullstorydev/grpcurl/releases GRPCURL_VERSION="1.8.5" diff --git a/ci/linux-install-openresty.sh b/ci/linux-install-openresty.sh index 8d24334173e9..aced7b1efad7 100755 --- a/ci/linux-install-openresty.sh +++ b/ci/linux-install-openresty.sh @@ -51,10 +51,7 @@ if [ "$OPENRESTY_VERSION" == "source" ]; then fi fi -export runtime_version=${APISIX_RUNTIME} -wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" -chmod +x build-apisix-runtime.sh -./build-apisix-runtime.sh latest +install_apisix_runtime() if [ ! "$ENABLE_FIPS" == "true" ]; then curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ diff --git a/ci/redhat-ci.sh b/ci/redhat-ci.sh index c10e047d4a48..5441f248cca9 100755 --- a/ci/redhat-ci.sh +++ b/ci/redhat-ci.sh @@ -38,10 +38,8 @@ install_dependencies() { yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo yum install -y openresty-pcre-devel openresty-zlib-devel - export runtime_version=${APISIX_RUNTIME} - wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - chmod +x build-apisix-runtime.sh - ./build-apisix-runtime.sh latest + install_apisix_runtime() + curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 058a87eed1de..69c41bc5c618 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -121,7 +121,8 @@ function multi_distro_uninstallation() { function install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME:?} - wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest rm build-apisix-runtime.sh From e84b8759cc6d4ec0501758296576923ae3c7f570 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 14:03:31 +0800 Subject: [PATCH 02/31] fix: remove trailing whitspace --- ci/redhat-ci.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/redhat-ci.sh b/ci/redhat-ci.sh index 5441f248cca9..df1d678fc423 100755 --- a/ci/redhat-ci.sh +++ b/ci/redhat-ci.sh @@ -39,7 +39,6 @@ install_dependencies() { yum install -y openresty-pcre-devel openresty-zlib-devel install_apisix_runtime() - curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf From c22ad18c9a0aafb7dda4ddbe9bcf983228bfe407 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 14:20:04 +0800 Subject: [PATCH 03/31] fix: ci lint --- ci/centos7-ci.sh | 2 +- ci/linux-install-openresty.sh | 2 +- ci/redhat-ci.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/centos7-ci.sh b/ci/centos7-ci.sh index 66417ebf5cb1..044c6239d3ce 100755 --- a/ci/centos7-ci.sh +++ b/ci/centos7-ci.sh @@ -44,7 +44,7 @@ install_dependencies() { yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo yum install -y openresty-pcre-devel openresty-zlib-devel - install_apisix_runtime() + install_apisix_runtime curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf diff --git a/ci/linux-install-openresty.sh b/ci/linux-install-openresty.sh index aced7b1efad7..f55bb114095f 100755 --- a/ci/linux-install-openresty.sh +++ b/ci/linux-install-openresty.sh @@ -51,7 +51,7 @@ if [ "$OPENRESTY_VERSION" == "source" ]; then fi fi -install_apisix_runtime() +install_apisix_runtime if [ ! "$ENABLE_FIPS" == "true" ]; then curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ diff --git a/ci/redhat-ci.sh b/ci/redhat-ci.sh index df1d678fc423..e6a50e2b6ebe 100755 --- a/ci/redhat-ci.sh +++ b/ci/redhat-ci.sh @@ -38,7 +38,7 @@ install_dependencies() { yum install -y yum-utils && yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo yum install -y openresty-pcre-devel openresty-zlib-devel - install_apisix_runtime() + install_apisix_runtime curl -o /usr/local/openresty/openssl3/ssl/openssl.cnf \ https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/conf/openssl3/openssl.cnf From be00c286fe68dfcc41469f7b313636ae05dc73d8 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 14:53:34 +0800 Subject: [PATCH 04/31] fix: ci lint --- ci/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/common.sh b/ci/common.sh index eded1e57753d..933941f71289 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -75,7 +75,7 @@ install_curl () { curl -V } -intall_apisix_runtime() { +install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" From 4ed4446dcbb54143c90760bbfc44a65ef95a6a02 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 15:29:38 +0800 Subject: [PATCH 05/31] fix: enable_http2 --- apisix/cli/ngx_tpl.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 532debe0ac4e..953f39047144 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -627,12 +627,13 @@ http { server { {% for _, item in ipairs(node_listen) do %} - listen {* item.ip *}:{* item.port *} default_server {% if item.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %}; + listen {* item.ip *}:{* item.port *} default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} {% if ssl.enable then %} {% for _, item in ipairs(ssl.listen) do %} - listen {* item.ip *}:{* item.port *} ssl default_server {% if item.enable_http2 then %} http2 {% end %} {% if enable_reuseport then %} reuseport {% end %}; + listen {* item.ip *}:{* item.port *} ssl default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} + {% if item.enable_http2 then %} http2 on {% end %} {% end %} {% if proxy_protocol and proxy_protocol.listen_http_port then %} listen {* proxy_protocol.listen_http_port *} default_server proxy_protocol; From 494c174048e3d0604e92687603e8b6a87852955e Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 16:12:03 +0800 Subject: [PATCH 06/31] fix: enable_http2 --- apisix/cli/ngx_tpl.lua | 2 +- conf/config-default.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 953f39047144..39e23f0053fa 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -633,7 +633,7 @@ http { {% for _, item in ipairs(ssl.listen) do %} listen {* item.ip *}:{* item.port *} ssl default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} - {% if item.enable_http2 then %} http2 on {% end %} + {% if ssl.http2 then %} http2 on; {% end %} {% end %} {% if proxy_protocol and proxy_protocol.listen_http_port then %} listen {* proxy_protocol.listen_http_port *} default_server proxy_protocol; diff --git a/conf/config-default.yaml b/conf/config-default.yaml index 6636bf096a5c..f758bd67cb02 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -94,6 +94,7 @@ apisix: ssl: enable: true + http2: true listen: # APISIX listening port for HTTPS traffic. - port: 9443 enable_http2: true From 0108c5fb3c25b657928e86fd2303047e78be858b Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 30 Jan 2024 17:01:06 +0800 Subject: [PATCH 07/31] fix: enable_http2 --- apisix/cli/ngx_tpl.lua | 3 ++- conf/config-default.yaml | 2 +- t/APISIX.pm | 3 ++- t/core/config-default.t | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 39e23f0053fa..72d3cb355b10 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -626,6 +626,8 @@ http { {% end %} server { + {% if enable_http2 then %} http2 on; {% end %} + {% for _, item in ipairs(node_listen) do %} listen {* item.ip *}:{* item.port *} default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} @@ -633,7 +635,6 @@ http { {% for _, item in ipairs(ssl.listen) do %} listen {* item.ip *}:{* item.port *} ssl default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} - {% if ssl.http2 then %} http2 on; {% end %} {% end %} {% if proxy_protocol and proxy_protocol.listen_http_port then %} listen {* proxy_protocol.listen_http_port *} default_server proxy_protocol; diff --git a/conf/config-default.yaml b/conf/config-default.yaml index f758bd67cb02..b750748f7ed6 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -19,6 +19,7 @@ # apisix: + enable_http2: true # node_listen: 9080 # APISIX listening port. node_listen: # APISIX listening ports. - 9080 @@ -94,7 +95,6 @@ apisix: ssl: enable: true - http2: true listen: # APISIX listening port for HTTPS traffic. - port: 9443 enable_http2: true diff --git a/t/APISIX.pm b/t/APISIX.pm index 6428de1c510d..b136e8aecc80 100644 --- a/t/APISIX.pm +++ b/t/APISIX.pm @@ -724,7 +724,8 @@ _EOC_ $config .= <<_EOC_; $ipv6_listen_conf - listen 1994 ssl http2; + listen 1994 ssl; + http2 on; ssl_certificate cert/apisix.crt; ssl_certificate_key cert/apisix.key; lua_ssl_trusted_certificate cert/apisix.crt; diff --git a/t/core/config-default.t b/t/core/config-default.t index 50c90cdcdabf..6227507e2cb8 100644 --- a/t/core/config-default.t +++ b/t/core/config-default.t @@ -121,6 +121,7 @@ node_listen: [1985,1986] === TEST 6: support listen multiple ports with array table --- yaml_config apisix: + enable_http2: true node_listen: - port: 1985 enable_http2: true From 93c7daa10c38f275fd3e92a5da43e67bde5f1932 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 1 Feb 2024 15:18:22 +0800 Subject: [PATCH 08/31] fix: ci lint --- apisix/cli/ngx_tpl.lua | 5 +++-- t/plugin/proxy-rewrite2.t | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua index 72d3cb355b10..0fdc27a29c96 100644 --- a/apisix/cli/ngx_tpl.lua +++ b/apisix/cli/ngx_tpl.lua @@ -626,8 +626,9 @@ http { {% end %} server { - {% if enable_http2 then %} http2 on; {% end %} - + {% if enable_http2 then %} + http2 on; + {% end %} {% for _, item in ipairs(node_listen) do %} listen {* item.ip *}:{* item.port *} default_server {% if enable_reuseport then %} reuseport {% end %}; {% end %} diff --git a/t/plugin/proxy-rewrite2.t b/t/plugin/proxy-rewrite2.t index a519968ba7d1..7096e4aad249 100644 --- a/t/plugin/proxy-rewrite2.t +++ b/t/plugin/proxy-rewrite2.t @@ -202,7 +202,7 @@ GET /echo X-Forwarded-Proto: http X-Forwarded-Proto: grpc --- response_headers -X-Forwarded-Proto: http +X-Forwarded-Proto: http, grpc From 7d125b2ebaa623b6e5eebad67452996f5d3b0b14 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 1 Feb 2024 16:58:54 +0800 Subject: [PATCH 09/31] fix: cli test --- conf/config-default.yaml | 2 +- t/cli/test_main.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/conf/config-default.yaml b/conf/config-default.yaml index b750748f7ed6..46c6b48b1270 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -19,7 +19,7 @@ # apisix: - enable_http2: true + enable_http2: true # only for test. # node_listen: 9080 # APISIX listening port. node_listen: # APISIX listening ports. - 9080 diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 3b0cab766d59..06b727044ca1 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -128,6 +128,7 @@ echo "passed: support multiple ports listen in http and https" echo " apisix: + enable_http2: true node_listen: - ip: 127.0.0.1 port: 9081 @@ -152,7 +153,7 @@ if [ $count_http_specific_ip -ne 2 ]; then exit 1 fi -count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server http2" conf/nginx.conf || true` +count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server" conf/nginx.conf || true` if [ $count_http_specific_ip_and_enable_http2 -ne 1 ]; then echo "failed: failed to support specific IP and enable http2 listen in http" exit 1 @@ -164,7 +165,7 @@ if [ $count_https_specific_ip -ne 2 ]; then exit 1 fi -count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server http2" conf/nginx.conf || true` +count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server" conf/nginx.conf || true` if [ $count_https_specific_ip_and_enable_http2 -ne 1 ]; then echo "failed: failed to support specific IP and enable http2 listen in https" exit 1 From 3c8dcaeac969e3a4c1c0ede742f50a41018351e6 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 1 Feb 2024 23:26:18 +0800 Subject: [PATCH 10/31] fix: cli test --- t/cli/test_main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 06b727044ca1..439ae1230b41 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -154,7 +154,7 @@ if [ $count_http_specific_ip -ne 2 ]; then fi count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server" conf/nginx.conf || true` -if [ $count_http_specific_ip_and_enable_http2 -ne 1 ]; then +if [ $count_http_specific_ip_and_enable_http2 -ne 2 ]; then echo "failed: failed to support specific IP and enable http2 listen in http" exit 1 fi @@ -166,7 +166,7 @@ if [ $count_https_specific_ip -ne 2 ]; then fi count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server" conf/nginx.conf || true` -if [ $count_https_specific_ip_and_enable_http2 -ne 1 ]; then +if [ $count_https_specific_ip_and_enable_http2 -ne 2 ]; then echo "failed: failed to support specific IP and enable http2 listen in https" exit 1 fi From 8e35febd5926490570da49d7292e5ebc97b2af5f Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Fri, 2 Feb 2024 12:11:13 +0800 Subject: [PATCH 11/31] fix: http2 with content-length header --- apisix/core/request.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index aa9dd03bf7bc..4751910026ac 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -282,6 +282,17 @@ function _M.get_body(max_size, ctx) end end + -- TODO: solve this issue correctly. + local var = ctx and ctx.var or ngx.var + local content_length = tonumber(var.http_content_length) or 0 + if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0") + and content_length == 0 then + -- Due to the stream processing feature of HTTP/2 or HTTP/3, + -- this api could potentially block the entire request. Therefore, + -- this api is effective only when HTTP/2 or HTTP/3 requests send content-length header. + -- For requests with versions lower than HTTP/2, this api can still be used without any problems. + return nil + end req_read_body() local req_body = req_get_body_data() From ce59af7ec5527912c3d0933c01e56ce46547d56d Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Fri, 2 Feb 2024 15:43:05 +0800 Subject: [PATCH 12/31] fix: ext-plugin --- apisix/plugins/ext-plugin/init.lua | 20 ++++++++++++-------- t/plugin/ext-plugin/sanity.t | 3 ++- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apisix/plugins/ext-plugin/init.lua b/apisix/plugins/ext-plugin/init.lua index 424f29dc4f9b..9683ba5ca80c 100644 --- a/apisix/plugins/ext-plugin/init.lua +++ b/apisix/plugins/ext-plugin/init.lua @@ -968,15 +968,13 @@ local function setup_runner(cmd) end runner = nil + -- TODO: fix this correctly. + -- local ok, err = events:post(events_list._source, events_list.runner_exit) + -- if not ok then + -- core.log.error("post event failure with ", events_list._source, ", error: ", err) + -- end - local ok, err = events:post(events_list._source, events_list.runner_exit) - if not ok then - core.log.error("post event failure with ", events_list._source, ", error: ", err) - end - - core.log.warn("respawn runner 3 seconds later with cmd: ", core.json.encode(cmd)) - core.utils.sleep(3) - core.log.warn("respawning new runner...") + core.log.warn("respawn runner with cmd: ", core.json.encode(cmd)) runner = spawn_proc(cmd) end end) @@ -1015,6 +1013,12 @@ function _M.exit_worker() local num = resty_signal.signum("TERM") runner:kill(num) + -- TODO: fix this correctly. + local ok, err = events:post(events_list._source, events_list.runner_exit) + if not ok then + core.log.error("post event failure with ", events_list._source, ", error: ", err) + end + -- give 1s to clean up the mess core.os.waitpid(pid, 1) -- then we KILL it via gc finalizer diff --git a/t/plugin/ext-plugin/sanity.t b/t/plugin/ext-plugin/sanity.t index 873a540a8215..e42ba59a3863 100644 --- a/t/plugin/ext-plugin/sanity.t +++ b/t/plugin/ext-plugin/sanity.t @@ -234,7 +234,7 @@ EXPIRE 3600 } --- error_log runner exited with reason: exit, status: 111 -respawn runner 3 seconds later with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"] +respawn runner with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"] @@ -297,6 +297,7 @@ receiving rpc type: 1 data length: --- error_log flush conf token lrucache flush conf token in shared dict +--- SKIP From db03194be890fe41c7179b9214ab0d8654ebf0b0 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Sat, 3 Feb 2024 22:18:22 +0800 Subject: [PATCH 13/31] fix: remove server ssl port in upstream-tls.t --- t/stream-node/upstream-tls.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index be6408ffacfd..16c39686da4c 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -34,14 +34,14 @@ add_block_preprocessor(sub { my $stream_config = $block->stream_config // ''; $stream_config .= <<_EOC_; server { - listen 8765 ssl; + listen 8765; ssl_certificate cert/apisix.crt; ssl_certificate_key cert/apisix.key; content_by_lua_block { local sock = ngx.req.socket() local data = sock:receive("1") - ngx.say("hello ", ngx.var.ssl_server_name) + ngx.say("hello") } } _EOC_ @@ -97,7 +97,7 @@ passed --- stream_request mmm --- stream_response -hello apisix_backend +hello @@ -112,7 +112,7 @@ hello apisix_backend local ssl_key = t.read_file("t/certs/apisix.key") local data = { cert = ssl_cert, key = ssl_key, - sni = "test.com", + snis = { "test.com" }, } local code, body = t.test('/apisix/admin/ssls/1', ngx.HTTP_PUT, @@ -139,4 +139,4 @@ passed mmm --- stream_sni: test.com --- response_body -hello test.com +hello From 9fcb781c3fc9adefc9b3f00c777412d521fc7e71 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Sun, 4 Feb 2024 14:29:20 +0800 Subject: [PATCH 14/31] fix: enable proxy_ssl in stream proxy --- t/APISIX.pm | 1 + t/stream-node/upstream-tls.t | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/t/APISIX.pm b/t/APISIX.pm index b136e8aecc80..67b78cf63fb9 100644 --- a/t/APISIX.pm +++ b/t/APISIX.pm @@ -483,6 +483,7 @@ _EOC_ if ($version =~ m/\/apisix-nginx-module/) { $stream_server_config .= <<_EOC_; proxy_ssl_server_name on; + proxy_ssl on; proxy_ssl_name \$upstream_sni; set \$upstream_sni "apisix_backend"; _EOC_ diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index 16c39686da4c..e34fc5a7aeb4 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -34,14 +34,14 @@ add_block_preprocessor(sub { my $stream_config = $block->stream_config // ''; $stream_config .= <<_EOC_; server { - listen 8765; + listen 8765 ssl; ssl_certificate cert/apisix.crt; ssl_certificate_key cert/apisix.key; content_by_lua_block { local sock = ngx.req.socket() local data = sock:receive("1") - ngx.say("hello") + ngx.say("hello ", ngx.var.ssl_server_name) } } _EOC_ @@ -97,7 +97,7 @@ passed --- stream_request mmm --- stream_response -hello +hello apisix_backend @@ -139,4 +139,4 @@ passed mmm --- stream_sni: test.com --- response_body -hello +hello test.com From bcc2ea539dcb4baf431c501a245535f4f51ef223 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Mon, 5 Feb 2024 09:57:58 +0800 Subject: [PATCH 15/31] Revert "fix: enable proxy_ssl in stream proxy" This reverts commit 9fcb781c3fc9adefc9b3f00c777412d521fc7e71. --- t/APISIX.pm | 1 - t/stream-node/upstream-tls.t | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/t/APISIX.pm b/t/APISIX.pm index 67b78cf63fb9..b136e8aecc80 100644 --- a/t/APISIX.pm +++ b/t/APISIX.pm @@ -483,7 +483,6 @@ _EOC_ if ($version =~ m/\/apisix-nginx-module/) { $stream_server_config .= <<_EOC_; proxy_ssl_server_name on; - proxy_ssl on; proxy_ssl_name \$upstream_sni; set \$upstream_sni "apisix_backend"; _EOC_ diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index e34fc5a7aeb4..16c39686da4c 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -34,14 +34,14 @@ add_block_preprocessor(sub { my $stream_config = $block->stream_config // ''; $stream_config .= <<_EOC_; server { - listen 8765 ssl; + listen 8765; ssl_certificate cert/apisix.crt; ssl_certificate_key cert/apisix.key; content_by_lua_block { local sock = ngx.req.socket() local data = sock:receive("1") - ngx.say("hello ", ngx.var.ssl_server_name) + ngx.say("hello") } } _EOC_ @@ -97,7 +97,7 @@ passed --- stream_request mmm --- stream_response -hello apisix_backend +hello @@ -139,4 +139,4 @@ passed mmm --- stream_sni: test.com --- response_body -hello test.com +hello From 7361f7b4276b02e40c512f81f6be546b7f7a196b Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Mon, 5 Feb 2024 11:37:35 +0800 Subject: [PATCH 16/31] chore: update --- t/stream-node/upstream-tls.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index 16c39686da4c..f500264fd1fd 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -34,7 +34,7 @@ add_block_preprocessor(sub { my $stream_config = $block->stream_config // ''; $stream_config .= <<_EOC_; server { - listen 8765; + listen 8765 ssl; ssl_certificate cert/apisix.crt; ssl_certificate_key cert/apisix.key; From 14226634e1dfd5bc89dbf4be444449c158e62563 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Mon, 5 Feb 2024 13:57:30 +0800 Subject: [PATCH 17/31] fix: update t/stream-node/upstream.t --- t/stream-node/upstream-tls.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index f500264fd1fd..e34fc5a7aeb4 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -41,7 +41,7 @@ add_block_preprocessor(sub { content_by_lua_block { local sock = ngx.req.socket() local data = sock:receive("1") - ngx.say("hello") + ngx.say("hello ", ngx.var.ssl_server_name) } } _EOC_ @@ -97,7 +97,7 @@ passed --- stream_request mmm --- stream_response -hello +hello apisix_backend @@ -139,4 +139,4 @@ passed mmm --- stream_sni: test.com --- response_body -hello +hello test.com From 39601f2612012e6758a8a7e6c09ddec5603f4abe Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Mon, 5 Feb 2024 15:39:46 +0800 Subject: [PATCH 18/31] chore: add comment --- ci/common.sh | 1 + t/stream-node/upstream-tls.t | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/common.sh b/ci/common.sh index 933941f71289..4dfd0f79ffcf 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -77,6 +77,7 @@ install_curl () { install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} + # I need to use script from my repo to test # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh diff --git a/t/stream-node/upstream-tls.t b/t/stream-node/upstream-tls.t index e34fc5a7aeb4..be6408ffacfd 100644 --- a/t/stream-node/upstream-tls.t +++ b/t/stream-node/upstream-tls.t @@ -112,7 +112,7 @@ hello apisix_backend local ssl_key = t.read_file("t/certs/apisix.key") local data = { cert = ssl_cert, key = ssl_key, - snis = { "test.com" }, + sni = "test.com", } local code, body = t.test('/apisix/admin/ssls/1', ngx.HTTP_PUT, From ddc631feb83f09f6c95ab37dda33ae5772c6028c Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 6 Feb 2024 21:09:16 +0800 Subject: [PATCH 19/31] fix: spawn sub-process in timer --- apisix/plugins/ext-plugin/init.lua | 21 ++++++++++----------- t/plugin/ext-plugin/sanity.t | 3 +-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/apisix/plugins/ext-plugin/init.lua b/apisix/plugins/ext-plugin/init.lua index 9683ba5ca80c..5f602789c106 100644 --- a/apisix/plugins/ext-plugin/init.lua +++ b/apisix/plugins/ext-plugin/init.lua @@ -935,13 +935,14 @@ end local runner local function setup_runner(cmd) - runner = spawn_proc(cmd) ngx_timer_at(0, function(premature) if premature then return end + runner = spawn_proc(cmd) + while not exiting() do while true do -- drain output @@ -969,12 +970,15 @@ local function setup_runner(cmd) runner = nil -- TODO: fix this correctly. - -- local ok, err = events:post(events_list._source, events_list.runner_exit) - -- if not ok then - -- core.log.error("post event failure with ", events_list._source, ", error: ", err) - -- end + local ok, err = events:post(events_list._source, events_list.runner_exit) + if not ok then + core.log.error("post event failure with ", events_list._source, ", error: ", err) + end - core.log.warn("respawn runner with cmd: ", core.json.encode(cmd)) + -- core.log.warn("respawn runner with cmd: ", core.json.encode(cmd)) + core.log.warn("respawn runner 3 seconds later with cmd: ", core.json.encode(cmd)) + core.utils.sleep(3) + core.log.warn("respawning new runner...") runner = spawn_proc(cmd) end end) @@ -1013,11 +1017,6 @@ function _M.exit_worker() local num = resty_signal.signum("TERM") runner:kill(num) - -- TODO: fix this correctly. - local ok, err = events:post(events_list._source, events_list.runner_exit) - if not ok then - core.log.error("post event failure with ", events_list._source, ", error: ", err) - end -- give 1s to clean up the mess core.os.waitpid(pid, 1) diff --git a/t/plugin/ext-plugin/sanity.t b/t/plugin/ext-plugin/sanity.t index e42ba59a3863..873a540a8215 100644 --- a/t/plugin/ext-plugin/sanity.t +++ b/t/plugin/ext-plugin/sanity.t @@ -234,7 +234,7 @@ EXPIRE 3600 } --- error_log runner exited with reason: exit, status: 111 -respawn runner with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"] +respawn runner 3 seconds later with cmd: ["t/plugin/ext-plugin/runner.sh","0.1"] @@ -297,7 +297,6 @@ receiving rpc type: 1 data length: --- error_log flush conf token lrucache flush conf token in shared dict ---- SKIP From c6b71fe5b9cbded64ec2554fb4ca4e980ffce94b Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 8 Feb 2024 08:53:33 +0800 Subject: [PATCH 20/31] chore: cleanup http2 --- apisix/cli/ops.lua | 10 +++++++++- apisix/plugins/ext-plugin/init.lua | 3 --- conf/config-default.yaml | 1 - t/cli/test_main.sh | 1 - t/core/config-default.t | 1 - 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index 836c87bce521..0a77487a6d5a 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -413,6 +413,7 @@ Please modify "admin_key" in conf/config.yaml . end end + local enable_http2_global = false local node_listen = {} -- listen in http, support multiple ports and specific IP, compatible with the original style if type(yaml_conf.apisix.node_listen) == "number" then @@ -427,7 +428,7 @@ Please modify "admin_key" in conf/config.yaml . local ip = value.ip local port = value.port local enable_ipv6 = false - local enable_http2 = value.enable_http2 + local enable_http2 = value.enable_http2 if ip == nil then ip = "0.0.0.0" @@ -443,6 +444,9 @@ Please modify "admin_key" in conf/config.yaml . if enable_http2 == nil then enable_http2 = false end + if enable_http2 == true then + enable_http2_global = true + end listen_table_insert(node_listen, "http", ip, port, enable_http2, enable_ipv6) @@ -473,12 +477,16 @@ Please modify "admin_key" in conf/config.yaml . if enable_http2 == nil then enable_http2 = false end + if enable_http2 == true then + enable_http2_global = true + end listen_table_insert(ssl_listen, "https", ip, port, enable_http2, enable_ipv6) end yaml_conf.apisix.ssl.listen = ssl_listen + yaml_conf.apisix.enable_http2 = enable_http2_global if yaml_conf.apisix.ssl.ssl_trusted_certificate ~= nil then local cert_path = yaml_conf.apisix.ssl.ssl_trusted_certificate diff --git a/apisix/plugins/ext-plugin/init.lua b/apisix/plugins/ext-plugin/init.lua index 5f602789c106..2631afd36fb3 100644 --- a/apisix/plugins/ext-plugin/init.lua +++ b/apisix/plugins/ext-plugin/init.lua @@ -969,13 +969,11 @@ local function setup_runner(cmd) end runner = nil - -- TODO: fix this correctly. local ok, err = events:post(events_list._source, events_list.runner_exit) if not ok then core.log.error("post event failure with ", events_list._source, ", error: ", err) end - -- core.log.warn("respawn runner with cmd: ", core.json.encode(cmd)) core.log.warn("respawn runner 3 seconds later with cmd: ", core.json.encode(cmd)) core.utils.sleep(3) core.log.warn("respawning new runner...") @@ -1017,7 +1015,6 @@ function _M.exit_worker() local num = resty_signal.signum("TERM") runner:kill(num) - -- give 1s to clean up the mess core.os.waitpid(pid, 1) -- then we KILL it via gc finalizer diff --git a/conf/config-default.yaml b/conf/config-default.yaml index 46c6b48b1270..6636bf096a5c 100755 --- a/conf/config-default.yaml +++ b/conf/config-default.yaml @@ -19,7 +19,6 @@ # apisix: - enable_http2: true # only for test. # node_listen: 9080 # APISIX listening port. node_listen: # APISIX listening ports. - 9080 diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 439ae1230b41..c6f627b0cdaf 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -128,7 +128,6 @@ echo "passed: support multiple ports listen in http and https" echo " apisix: - enable_http2: true node_listen: - ip: 127.0.0.1 port: 9081 diff --git a/t/core/config-default.t b/t/core/config-default.t index 6227507e2cb8..50c90cdcdabf 100644 --- a/t/core/config-default.t +++ b/t/core/config-default.t @@ -121,7 +121,6 @@ node_listen: [1985,1986] === TEST 6: support listen multiple ports with array table --- yaml_config apisix: - enable_http2: true node_listen: - port: 1985 enable_http2: true From f979676d06b1337e15481882cb762d36e449f232 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 8 Feb 2024 08:54:45 +0800 Subject: [PATCH 21/31] chore: cleanup --- apisix/cli/ops.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index 0a77487a6d5a..918d1c81bdfb 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -428,7 +428,7 @@ Please modify "admin_key" in conf/config.yaml . local ip = value.ip local port = value.port local enable_ipv6 = false - local enable_http2 = value.enable_http2 + local enable_http2 = value.enable_http2 if ip == nil then ip = "0.0.0.0" From ef98f7002a9c4f25a18b03d7654751c384863d7c Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 20 Feb 2024 09:42:18 +0800 Subject: [PATCH 22/31] fix: lint error --- apisix/core/request.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index 4751910026ac..02f78ac10bda 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -290,7 +290,8 @@ function _M.get_body(max_size, ctx) -- Due to the stream processing feature of HTTP/2 or HTTP/3, -- this api could potentially block the entire request. Therefore, -- this api is effective only when HTTP/2 or HTTP/3 requests send content-length header. - -- For requests with versions lower than HTTP/2, this api can still be used without any problems. + -- For requests with versions lower than HTTP/2, this api can still be used without + --- any problems. return nil end req_read_body() From 22d46db26f75ec385fec203b204896ba4824c4ed Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Tue, 20 Feb 2024 16:56:49 +0800 Subject: [PATCH 23/31] chore: grep 'http2 on' --- t/cli/test_main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index c6f627b0cdaf..32255603a6f3 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -164,8 +164,8 @@ if [ $count_https_specific_ip -ne 2 ]; then exit 1 fi -count_https_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:944. ssl default_server" conf/nginx.conf || true` -if [ $count_https_specific_ip_and_enable_http2 -ne 2 ]; then +count_https_specific_ip_and_enable_http2=`grep -c "http2 on" conf/nginx.conf || true` +if [ $count_https_specific_ip_and_enable_http2 -ne 1 ]; then echo "failed: failed to support specific IP and enable http2 listen in https" exit 1 fi From 1dd968ca647629ce156eebfb51256cc1afa7822b Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Wed, 21 Feb 2024 15:47:36 +0800 Subject: [PATCH 24/31] chore: use apisix-runtime/1.2.0 --- .requirements | 2 +- ci/common.sh | 4 +--- utils/install-dependencies.sh | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.requirements b/.requirements index b5d22118a3c4..bbfa42c49801 100644 --- a/.requirements +++ b/.requirements @@ -17,4 +17,4 @@ APISIX_PACKAGE_NAME=apisix -APISIX_RUNTIME=1.1.1 +APISIX_RUNTIME=1.2.0 diff --git a/ci/common.sh b/ci/common.sh index 4dfd0f79ffcf..7e9f65e385b6 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -77,9 +77,7 @@ install_curl () { install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} - # I need to use script from my repo to test - # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest } diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 69c41bc5c618..058a87eed1de 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -121,8 +121,7 @@ function multi_distro_uninstallation() { function install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME:?} - # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/upgrade_openresty-1.25.3.1/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest rm build-apisix-runtime.sh From 9736157cd1d052961256d8e74572b6807eb8da97 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Wed, 21 Feb 2024 16:01:56 +0800 Subject: [PATCH 25/31] chore: grep 'http2 on' --- t/cli/test_main.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh index 32255603a6f3..1835ef5bbe27 100755 --- a/t/cli/test_main.sh +++ b/t/cli/test_main.sh @@ -152,8 +152,8 @@ if [ $count_http_specific_ip -ne 2 ]; then exit 1 fi -count_http_specific_ip_and_enable_http2=`grep -c "listen 127.0.0..:908. default_server" conf/nginx.conf || true` -if [ $count_http_specific_ip_and_enable_http2 -ne 2 ]; then +count_http_specific_ip_and_enable_http2=`grep -c "http2 on" conf/nginx.conf || true` +if [ $count_http_specific_ip_and_enable_http2 -ne 1 ]; then echo "failed: failed to support specific IP and enable http2 listen in http" exit 1 fi From 25fd3837b0d9158a7cdf2272aa2327bffb9dd27a Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Wed, 21 Feb 2024 22:15:56 +0800 Subject: [PATCH 26/31] chore: test ci --- ci/common.sh | 3 ++- utils/install-dependencies.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ci/common.sh b/ci/common.sh index 7e9f65e385b6..5c931dccb298 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -77,7 +77,8 @@ install_curl () { install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} - wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + wget "https://github.com/zll600/apisix-build-tools/blob/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest } diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 058a87eed1de..1fce87ff3ef8 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -121,7 +121,8 @@ function multi_distro_uninstallation() { function install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME:?} - wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" + wget "https://github.com/zll600/apisix-build-tools/blob/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest rm build-apisix-runtime.sh From 4eadeca705566f6db5772266c635b069444e7cd5 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Wed, 21 Feb 2024 22:20:13 +0800 Subject: [PATCH 27/31] chore: test ci --- ci/common.sh | 2 +- utils/install-dependencies.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/common.sh b/ci/common.sh index 5c931dccb298..34a4f7db6ded 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -78,7 +78,7 @@ install_curl () { install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://github.com/zll600/apisix-build-tools/blob/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest } diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 1fce87ff3ef8..6b3e55bdaa9b 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -122,7 +122,7 @@ function multi_distro_uninstallation() { function install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME:?} # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://github.com/zll600/apisix-build-tools/blob/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest rm build-apisix-runtime.sh From fbae45e299278c783eeaa312d61884c20ba23bba Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Thu, 22 Feb 2024 19:06:38 +0800 Subject: [PATCH 28/31] chore(ci): disable gm ci --- .github/workflows/{gm-cron.yaml => gm-cron.yaml.disabled} | 0 .github/workflows/{gm.yml => gm.yml.disabled} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{gm-cron.yaml => gm-cron.yaml.disabled} (100%) rename .github/workflows/{gm.yml => gm.yml.disabled} (100%) diff --git a/.github/workflows/gm-cron.yaml b/.github/workflows/gm-cron.yaml.disabled similarity index 100% rename from .github/workflows/gm-cron.yaml rename to .github/workflows/gm-cron.yaml.disabled diff --git a/.github/workflows/gm.yml b/.github/workflows/gm.yml.disabled similarity index 100% rename from .github/workflows/gm.yml rename to .github/workflows/gm.yml.disabled From e184acff5270c2ab98dc450438b18f910329217b Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Fri, 23 Feb 2024 13:11:03 +0800 Subject: [PATCH 29/31] chore: revert install_apisix_runtime --- ci/common.sh | 3 +-- utils/install-dependencies.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/common.sh b/ci/common.sh index 34a4f7db6ded..7e9f65e385b6 100644 --- a/ci/common.sh +++ b/ci/common.sh @@ -77,8 +77,7 @@ install_curl () { install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME} - # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest } diff --git a/utils/install-dependencies.sh b/utils/install-dependencies.sh index 6b3e55bdaa9b..058a87eed1de 100755 --- a/utils/install-dependencies.sh +++ b/utils/install-dependencies.sh @@ -121,8 +121,7 @@ function multi_distro_uninstallation() { function install_apisix_runtime() { export runtime_version=${APISIX_RUNTIME:?} - # wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" - wget "https://raw.githubusercontent.com/zll600/apisix-build-tools/5f07effaca6b4ae227cb578a120c89637952e415/build-apisix-runtime.sh" + wget "https://raw.githubusercontent.com/api7/apisix-build-tools/apisix-runtime/${APISIX_RUNTIME}/build-apisix-runtime.sh" chmod +x build-apisix-runtime.sh ./build-apisix-runtime.sh latest rm build-apisix-runtime.sh From 69ef089d301d52a0cfc6fc49036b1d46220018ab Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Fri, 23 Feb 2024 13:15:26 +0800 Subject: [PATCH 30/31] chore: report 400 for http2/3 request without content-length header --- apisix/core/request.lua | 19 ++++++-------- t/plugin/azure-functions.t | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/apisix/core/request.lua b/apisix/core/request.lua index 02f78ac10bda..0c614edf1b20 100644 --- a/apisix/core/request.lua +++ b/apisix/core/request.lua @@ -282,17 +282,14 @@ function _M.get_body(max_size, ctx) end end - -- TODO: solve this issue correctly. - local var = ctx and ctx.var or ngx.var - local content_length = tonumber(var.http_content_length) or 0 - if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0") - and content_length == 0 then - -- Due to the stream processing feature of HTTP/2 or HTTP/3, - -- this api could potentially block the entire request. Therefore, - -- this api is effective only when HTTP/2 or HTTP/3 requests send content-length header. - -- For requests with versions lower than HTTP/2, this api can still be used without - --- any problems. - return nil + -- check content-length header for http2/http3 + do + local var = ctx and ctx.var or ngx.var + local content_length = tonumber(var.http_content_length) + if (var.server_protocol == "HTTP/2.0" or var.server_protocol == "HTTP/3.0") + and not content_length then + return nil, "HTTP2/HTTP3 request without a Content-Length header" + end end req_read_body() diff --git a/t/plugin/azure-functions.t b/t/plugin/azure-functions.t index 2ab2f91178cb..d48198a22b1a 100644 --- a/t/plugin/azure-functions.t +++ b/t/plugin/azure-functions.t @@ -189,6 +189,8 @@ X-Extra-Header: MUST --- http2 --- request GET /azure +--- more_headers +Content-Length: 0 --- response_body faas invoked @@ -208,6 +210,8 @@ server: APISIX/2.10.2 --- http2 --- request HEAD /azure +--- more_headers +Content-Length: 0 --- response_headers Connection: Upgrade: @@ -456,3 +460,51 @@ invocation /api/http/trigger successful } --- response_body invocation /api successful + + + +=== TEST 14: create route with azure-function plugin enabled +--- config + location /t { + content_by_lua_block { + local t = require("lib.test_admin").test + + local code, body = t('/apisix/admin/routes/1', + ngx.HTTP_PUT, + [[{ + "plugins": { + "azure-functions": { + "function_uri": "http://localhost:8765/httptrigger" + } + }, + "upstream": { + "nodes": { + "127.0.0.1:1982": 1 + }, + "type": "roundrobin" + }, + "uri": "/azure" + }]] + ) + + if code >= 300 then + ngx.status = code + ngx.say("fail") + return + end + + ngx.say(body) + } + } +--- response_body +passed + + + +=== TEST 15: http2 failed to check response body and headers +--- http2 +--- request +GET /azure +--- error_code: 400 +--- error_log +HTTP2/HTTP3 request without a Content-Length header, \ No newline at end of file From dc3c05c8aae9afcad553694a8ac98a992b749453 Mon Sep 17 00:00:00 2001 From: zll600 <3400692417@qq.com> Date: Fri, 23 Feb 2024 13:21:21 +0800 Subject: [PATCH 31/31] fix: lint error --- t/plugin/azure-functions.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/plugin/azure-functions.t b/t/plugin/azure-functions.t index d48198a22b1a..72f9bbc6b2f7 100644 --- a/t/plugin/azure-functions.t +++ b/t/plugin/azure-functions.t @@ -507,4 +507,4 @@ passed GET /azure --- error_code: 400 --- error_log -HTTP2/HTTP3 request without a Content-Length header, \ No newline at end of file +HTTP2/HTTP3 request without a Content-Length header,