ngx_http_v2_module
Serve HTTP/2 over TLS with ALPN or over cleartext TCP
Overview
ngx_http_v2_module provides support for HTTP/2 (RFC 9113). Since 1.25.1 it is switched on with the http2 directive in the http or server context rather than a listen parameter, and applies to every listen socket in that server.
Accepting HTTP/2 over TLS relies on the ALPN extension, available since OpenSSL 1.0.2, and if ssl_prefer_server_ciphers is on the cipher list must comply with the RFC 9113 Appendix A black list. The $http2 variable holds the negotiated identifier, h2 over TLS, h2c over cleartext, or an empty string. Server push and several protocol-specific timeouts were made obsolete in 1.25.1 and 1.19.7, with early_hints, keepalive_timeout and client_header_timeout taking their place.
It is an official nginx module, present since 1.9.5, and is not built by default upstream, so it needs the --with-http_v2_module configure parameter. Its typical use is enabling multiplexed HTTPS on any server block that already has a TLS certificate.
Key directives
http2Enables the HTTP/2 protocol for a server, default off; appeared in 1.25.1.http2_max_concurrent_streamsSets the maximum number of concurrent HTTP/2 streams in one connection, default 128.http2_body_preread_sizePer-request buffer where the request body may be saved before processing starts, default 64k.http2_chunk_sizeMaximum size of the chunks the response body is sliced into, default 8k; too high impairs prioritization.http2_recv_buffer_sizeSize of the per-worker input buffer, http context only, default 256k.$http2Negotiated protocol identifier: h2 over TLS, h2c over cleartext TCP, or an empty string.Example
Availability
Compiled into every n.wtf nginx binary. Install nginx-extras and the directives above work out of the box, no load_module line needed.