Skip to content

Commit e31eb87

Browse files
committed
feat: support HTTP3
1 parent fde92c3 commit e31eb87

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

base.template

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ server {
77
# Generated with nginx-le-setup
88
listen 80;
99
listen [::]:80;
10-
listen 443 ssl${HTTP2};
11-
listen [::]:443 ssl${HTTP2};
10+
listen 443 ssl http2;
11+
${HTTP3:+listen 443 http3 reuseport;}
12+
listen [::]:443 ssl http2;
13+
${HTTP3:+listen [::]:443 http3 reuseport;}
1214
server_name ${VDOMAINS};
1315

1416
${CONFIG}
@@ -46,6 +48,11 @@ server {
4648
return 301 https://\$server_name\$request_uri;
4749
}
4850

51+
add_header X-protocol $server_protocol always;
52+
53+
${HTTP3:+ add_header alt-svc 'h3=\":443\"; ma=86400';}
54+
${HTTP3:+ quic_retry on;}
55+
4956
# HSTS (ngx_http_headers_module is required) 6 months
5057
add_header Strict-Transport-Security \"max-age=15768000; ${HSTS}\";
5158

nginx-le-setup.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
#
44

55
NGINX_DIR="/etc/nginx"
6-
HTTP2_MIN_VERSION=1.9.5
76
# Internal variables
87
CONFIRM=0
98
FORCE=0
109
_BACKUP=0
11-
HTTP2=""
10+
HTTP3=""
1211
# shellcheck disable=SC2034
1312
HSTS=""
1413
_CERBOT_EXTRA_ARGS=""
@@ -49,9 +48,9 @@ _initialize_variables() {
4948

5049
_NGINX_VERSION=$(nginx -v 2>&1 | cut -d '/' -f 2)
5150

52-
if _version_gt "${_NGINX_VERSION}" "${HTTP2_MIN_VERSION}"; then
51+
if (nginx -V 2>&1 | grep http_v3); then
5352
# shellcheck disable=SC2034
54-
HTTP2=" http2"
53+
HTTP3=1
5554
fi
5655

5756
# Check for a config file

0 commit comments

Comments
 (0)