This is an automated email from the ASF dual-hosted git repository.
shreemaanabhishek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git
The following commit(s) were added to refs/heads/master by this push:
new 8c4eff25c refactor(http3): use http3 instead of quic (#11010)
8c4eff25c is described below
commit 8c4eff25c61eced64f5486d3e9fbeb2c659e8732
Author: Leigang Zhang <[email protected]>
AuthorDate: Wed Mar 13 12:03:44 2024 +0800
refactor(http3): use http3 instead of quic (#11010)
---
.github/workflows/{quic.yml => http3.yml} | 10 +++++-----
apisix/cli/ngx_tpl.lua | 5 ++++-
apisix/cli/ops.lua | 20 +++++++++++++-------
apisix/cli/schema.lua | 2 +-
conf/config-default.yaml | 4 ++--
t/APISIX.pm | 2 +-
t/cli/test_main.sh | 8 +++++++-
t/{quic => http3}/admin/basic.t | 0
8 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/.github/workflows/quic.yml b/.github/workflows/http3.yml
similarity index 97%
rename from .github/workflows/quic.yml
rename to .github/workflows/http3.yml
index abaf39988..84b450b82 100644
--- a/.github/workflows/quic.yml
+++ b/.github/workflows/http3.yml
@@ -1,4 +1,4 @@
-name: QUIC
+name: HTTP/3
on:
push:
@@ -32,7 +32,7 @@ jobs:
- lua-resty-worker-events
- lua-resty-events
test_dir:
- - t/quic/admin
+ - t/http3/admin
runs-on: ${{ matrix.platform }}
timeout-minutes: 90
@@ -72,13 +72,13 @@ jobs:
id: test_env
run: |
test_dir="${{ matrix.test_dir }}"
- if [[ $test_dir =~ 't/quic/plugin' ]]; then
+ if [[ $test_dir =~ 't/http3/plugin' ]]; then
echo "type=plugin" >>$GITHUB_OUTPUT
fi
- if [[ $test_dir =~ 't/quic/admin' ]]; then
+ if [[ $test_dir =~ 't/http3/admin' ]]; then
echo "type=first" >>$GITHUB_OUTPUT
fi
- if [[ $test_dir =~ ' t/quic/xrpc' ]]; then
+ if [[ $test_dir =~ ' t/http3/xrpc' ]]; then
echo "type=last" >>$GITHUB_OUTPUT
fi
diff --git a/apisix/cli/ngx_tpl.lua b/apisix/cli/ngx_tpl.lua
index 9642a3605..4b7ff4102 100644
--- a/apisix/cli/ngx_tpl.lua
+++ b/apisix/cli/ngx_tpl.lua
@@ -631,12 +631,15 @@ http {
{% if enable_http2 then %}
http2 on;
{% end %}
+ {% if enable_http3_in_server_context then %}
+ http3 on;
+ {% end %}
{% for _, item in ipairs(node_listen) do %}
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 %}
- {% if item.enable_quic then %}
+ {% if item.enable_http3 then %}
listen {* item.ip *}:{* item.port *} quic default_server {% if
enable_reuseport then %} reuseport {% end %};
listen {* item.ip *}:{* item.port *} ssl default_server;
{% else %}
diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua
index 73b9c1d13..37c427458 100644
--- a/apisix/cli/ops.lua
+++ b/apisix/cli/ops.lua
@@ -380,7 +380,7 @@ Please modify "admin_key" in conf/config.yaml .
local ip_port_to_check = {}
local function listen_table_insert(listen_table, scheme, ip, port,
- enable_http2, enable_quic, enable_ipv6)
+ enable_http2, enable_http3, enable_ipv6)
if type(ip) ~= "string" then
util.die(scheme, " listen ip format error, must be string", "\n")
end
@@ -402,7 +402,7 @@ Please modify "admin_key" in conf/config.yaml .
ip = ip,
port = port,
enable_http2 = enable_http2,
- enable_quic = enable_quic
+ enable_http3 = enable_http3
})
ip_port_to_check[addr] = scheme
end
@@ -417,7 +417,7 @@ Please modify "admin_key" in conf/config.yaml .
ip = ip,
port = port,
enable_http2 = enable_http2,
- enable_quic = enable_quic
+ enable_http3 = enable_http3
})
ip_port_to_check[addr] = scheme
end
@@ -466,6 +466,7 @@ Please modify "admin_key" in conf/config.yaml .
end
yaml_conf.apisix.node_listen = node_listen
+ local enable_http3_in_server_context = false
local ssl_listen = {}
-- listen in https, support multiple ports, support specific IP
for _, value in ipairs(yaml_conf.apisix.ssl.listen) do
@@ -473,7 +474,7 @@ Please modify "admin_key" in conf/config.yaml .
local port = value.port
local enable_ipv6 = false
local enable_http2 = value.enable_http2
- local enable_quic = value.enable_quic
+ local enable_http3 = value.enable_http3
if ip == nil then
ip = "0.0.0.0"
@@ -493,16 +494,21 @@ Please modify "admin_key" in conf/config.yaml .
enable_http2_global = true
end
- if enable_quic == nil then
- enable_quic = false
+ if enable_http3 == nil then
+ enable_http3 = false
+ end
+ if enable_http3 == true then
+ enable_http3_in_server_context = true
end
listen_table_insert(ssl_listen, "https", ip, port,
- enable_http2, enable_quic, enable_ipv6)
+ enable_http2, enable_http3, enable_ipv6)
end
yaml_conf.apisix.ssl.listen = ssl_listen
yaml_conf.apisix.enable_http2 = enable_http2_global
+ yaml_conf.apisix.enable_http3_in_server_context =
enable_http3_in_server_context
+
if yaml_conf.apisix.ssl.ssl_trusted_certificate ~= nil then
local cert_path = yaml_conf.apisix.ssl.ssl_trusted_certificate
diff --git a/apisix/cli/schema.lua b/apisix/cli/schema.lua
index 3eae5ed75..4d1e0470a 100644
--- a/apisix/cli/schema.lua
+++ b/apisix/cli/schema.lua
@@ -221,7 +221,7 @@ local config_schema = {
enable_http2 = {
type = "boolean",
},
- enable_quic = {
+ enable_http3 = {
type = "boolean",
},
}
diff --git a/conf/config-default.yaml b/conf/config-default.yaml
index 7b409a7ba..64bf20b75 100755
--- a/conf/config-default.yaml
+++ b/conf/config-default.yaml
@@ -97,11 +97,11 @@ apisix:
listen: # APISIX listening port for
HTTPS traffic.
- port: 9443
enable_http2: true
- enable_quic: false # Enable QUIC or HTTP/3. If
not set default to `false`.
+ enable_http3: false # Enable HTTP/3 (with QUIC).
If not set default to `false`.
# - ip: 127.0.0.3 # If not set, default to
`0.0.0.0`.
# port: 9445
# enable_http2: true
- # enable_quic: true
+ # enable_http3: true
# ssl_trusted_certificate: /path/to/ca-cert # Set the path to CA
certificates used to verify client
# certificates in the PEM
format.
ssl_protocols: TLSv1.2 TLSv1.3 # TLS versions supported.
diff --git a/t/APISIX.pm b/t/APISIX.pm
index 5e61dcf76..616057c4b 100644
--- a/t/APISIX.pm
+++ b/t/APISIX.pm
@@ -671,7 +671,6 @@ _EOC_
$a6_ngx_directives
server {
- listen 1983 quic reuseport;
listen 1983 ssl;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
@@ -730,6 +729,7 @@ _EOC_
listen 1994 quic reuseport;
listen 1994 ssl;
http2 on;
+ http3 on;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
lua_ssl_trusted_certificate cert/apisix.crt;
diff --git a/t/cli/test_main.sh b/t/cli/test_main.sh
index 7248b2c7f..98b2db579 100755
--- a/t/cli/test_main.sh
+++ b/t/cli/test_main.sh
@@ -142,7 +142,7 @@ apisix:
- ip: 127.0.0.4
port: 9445
enable_http2: true
- enable_quic: true
+ enable_http3: true
" > conf/config.yaml
make init
@@ -177,6 +177,12 @@ if [ $count_https_specific_ip_and_enable_quic -ne 1 ]; then
exit 1
fi
+count_https_specific_ip_and_enable_http3=`grep -c "http3 on" conf/nginx.conf
|| true`
+if [ $count_https_specific_ip_and_enable_http3 -ne 1 ]; then
+ echo "failed: failed to support specific IP and enable http3 listen in
https"
+ exit 1
+fi
+
echo "passed: support specific IP listen in http and https"
# check default env
diff --git a/t/quic/admin/basic.t b/t/http3/admin/basic.t
similarity index 100%
rename from t/quic/admin/basic.t
rename to t/http3/admin/basic.t