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

refactor(http3): use http3 instead of quic #11010

Merged
merged 2 commits into from
Mar 13, 2024
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
10 changes: 5 additions & 5 deletions .github/workflows/quic.yml → .github/workflows/http3.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: QUIC
name: HTTP/3

on:
push:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion apisix/cli/ngx_tpl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
20 changes: 13 additions & 7 deletions apisix/cli/ops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -466,14 +466,15 @@ 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
local ip = value.ip
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"
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apisix/cli/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ local config_schema = {
enable_http2 = {
type = "boolean",
},
enable_quic = {
enable_http3 = {
type = "boolean",
},
}
Expand Down
4 changes: 2 additions & 2 deletions conf/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion t/APISIX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,6 @@ _EOC_
$a6_ngx_directives

server {
listen 1983 quic reuseport;
shreemaan-abhishek marked this conversation as resolved.
Show resolved Hide resolved
listen 1983 ssl;
ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
Expand Down Expand Up @@ -730,6 +729,7 @@ _EOC_
listen 1994 quic reuseport;
listen 1994 ssl;
http2 on;
http3 on;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being added now? Why wasn't this added during the main feature PR?

Copy link
Contributor Author

@zll600 zll600 Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The http3 directive default is on. And I forgot to add it in the main feature PR.#10989

ssl_certificate cert/apisix.crt;
ssl_certificate_key cert/apisix.key;
lua_ssl_trusted_certificate cert/apisix.crt;
Expand Down
8 changes: 7 additions & 1 deletion t/cli/test_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
Loading