From 67421ab22861848623a27335923da8446f2848dd Mon Sep 17 00:00:00 2001 From: Charlotte Som Date: Tue, 27 Jan 2026 09:07:58 +0000 Subject: [PATCH] add http/3 helper func --- ngx.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ngx.ts b/ngx.ts index 7ea3922..87e79d5 100644 --- a/ngx.ts +++ b/ngx.ts @@ -135,6 +135,20 @@ export const listen = (...extras: string[]) => `http2 on`, ]); +/** + * create http/3 (quic) listen directives (+ supporting alt-svc header). + */ +export const http3 = ( + opts: { + /** max age for alt-svc header */ ma?: number; + } = {}, +) => + conform([ + "listen 443 quic reuseport", + "listen [::]:443 quic reuseport", + `add_header Alt-Svc 'h3=":443"; ma=${opts.ma ?? 86400}'`, + ]); + /** * create a server_name nginx directive. * @@ -176,5 +190,5 @@ export const letsEncrypt = ( */ export default Object.assign( (value?: string, children?: LooseConfigNode[]) => ngx(value, children), - { NGX_VERSION, listen, letsEncrypt, serverName }, + { NGX_VERSION, listen, letsEncrypt, serverName, http3 }, );