Skip to content

Commit f59c4ca

Browse files
authored
Add patch for NGINX 1.19.7+ and QUIC (#192)
1 parent d0a05c7 commit f59c4ca

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The script might work on ARM-based architectures, but it's only being regularly
2222

2323
- [LibreSSL from source](http://www.libressl.org/) (CHACHA20, ALPN for HTTP/2, X25519, P-521)
2424
- [OpenSSL from source](https://www.openssl.org/) (TLS 1.3, CHACHA20, ALPN for HTTP/2, X25519, P-521)
25-
- [Cloudflare's patch for HTTP/3](https://blog.cloudflare.com/experiment-with-http-3-using-nginx-and-quiche/) with [Quiche](https://github.com/cloudflare/quiche) and [BoringSSL](https://github.com/google/boringssl). (⚠️ the patch [doesn't work for versions > 1.19.6](https://github.com/cloudflare/quiche/issues/859).)
25+
- [Cloudflare's patch for HTTP/3](https://blog.cloudflare.com/experiment-with-http-3-using-nginx-and-quiche/) with [Quiche](https://github.com/cloudflare/quiche) and [BoringSSL](https://github.com/google/boringssl).
2626
- [Cloudflare's TLS Dynamic Record Resizing patch](https://blog.cloudflare.com/optimizing-tls-over-tcp-to-reduce-latency/) maintained by [nginx-modules](https://github.com/nginx-modules/ngx_http_tls_dyn_size).
2727
- [Cloudflare's HTTP/2 HPACK encoding patch](https://blog.cloudflare.com/hpack-the-silent-killer-feature-of-http-2/) ([original patch](https://github.com/cloudflare/sslconfig/blob/master/patches/nginx_1.13.1_http2_hpack.patch), [fixed patch](https://github.com/hakasenyang/openssl-patch/blob/master/nginx_hpack_push_1.15.3.patch))
2828
- [ngx_pagespeed](https://github.com/pagespeed/ngx_pagespeed): Google performance module

nginx-autoinstall.sh

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ case $OPTION in
9999
echo ""
100100
echo "Modules to install :"
101101
while [[ $HTTP3 != "y" && $HTTP3 != "n" ]]; do
102-
read -rp " HTTP/3 (⚠️ Patch by Cloudflare for versions <= 1.19.7, will install BoringSSL, Quiche, Rust and Go) [y/n]: " -e -i n HTTP3
102+
read -rp " HTTP/3 (⚠️ Patch by Cloudflare, will install BoringSSL, Quiche, Rust and Go) [y/n]: " -e -i n HTTP3
103103
done
104104
while [[ $TLSDYN != "y" && $TLSDYN != "n" ]]; do
105105
read -rp " Cloudflare's TLS Dynamic Record Resizing patch [y/n]: " -e -i n TLSDYN
@@ -520,6 +520,10 @@ case $OPTION in
520520
# Apply actual patch
521521
patch -p01 </usr/local/src/nginx/modules/quiche/extras/nginx/nginx-1.16.patch
522522

523+
# Apply patch for nginx > 1.19.7 (source: https://github.com/cloudflare/quiche/issues/936#issuecomment-857618081)
524+
wget https://raw.githubusercontent.com/angristan/nginx-autoinstall/master/patches/nginx-http3-1.19.7.patch -O nginx-http3.patch
525+
patch -p01 <nginx-http3.patch
526+
523527
NGINX_OPTIONS=$(
524528
echo "$NGINX_OPTIONS"
525529
echo --with-openssl=/usr/local/src/nginx/modules/quiche/deps/boringssl --with-quiche=/usr/local/src/nginx/modules/quiche

patches/nginx-http3-1.19.7.patch

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
2+
index d9d28cf..0c6dbba 100644
3+
--- a/src/http/ngx_http_request.c
4+
+++ b/src/http/ngx_http_request.c
5+
@@ -361,7 +361,9 @@ ngx_http_init_connection(ngx_connection_t *c)
6+
7+
/* We already have a UDP packet in the connection buffer, so we don't
8+
* need to wait for another read event to kick-off the handshake. */
9+
- ngx_add_timer(rev, c->listening->post_accept_timeout);
10+
+ cscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
11+
+ ngx_http_core_module);
12+
+ ngx_add_timer(rev, cscf->client_header_timeout);
13+
ngx_http_quic_handshake(rev);
14+
return;
15+
}
16+
@@ -1102,6 +1104,7 @@ ngx_http_quic_handshake(ngx_event_t *rev)
17+
ngx_http_connection_t *hc;
18+
ngx_http_v3_srv_conf_t *qscf;
19+
ngx_http_ssl_srv_conf_t *sscf;
20+
+ ngx_http_core_srv_conf_t *cscf;
21+
22+
c = rev->data;
23+
hc = c->data;
24+
@@ -1142,7 +1145,9 @@ ngx_http_quic_handshake(ngx_event_t *rev)
25+
if (rc == NGX_AGAIN) {
26+
27+
if (!rev->timer_set) {
28+
- ngx_add_timer(rev, c->listening->post_accept_timeout);
29+
+ cscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
30+
+ ngx_http_core_module);
31+
+ ngx_add_timer(rev, cscf->client_header_timeout);
32+
}
33+
34+
c->ssl->handler = ngx_http_ssl_handshake_handler;

0 commit comments

Comments
 (0)