add http/3 helper func

This commit is contained in:
Charlotte Som 2026-01-27 09:07:58 +00:00
parent 5752044098
commit 67421ab228

16
ngx.ts
View file

@ -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 },
);