http_v2 module#

Provides support for HTTP/2.

Example Configuration#

server {
    listen 443 ssl;

    http2 on;

    ssl_certificate server.crt;
    ssl_certificate_key server.key;
}

Important

Note that accepting HTTP/2 connections over TLS requires the “Application-Layer Protocol Negotiation” (ALPN) TLS extension support, which is available since OpenSSL version 1.0.2.

If the ssl_prefer_server_ciphers directive is set to the value “on”, the ciphers should be configured to comply with RFC 9113, Appendix A black list and supported by clients.

Directives#

http2#

New in version 1.2.0.

Syntax:

http2 on | off;

Default:

http2 off;

Context:

http, server

Enables the HTTP/2 protocol.

http2_body_preread_size#

Syntax:

http2_body_preread_size size;

Default:

Context:

http, server

Sets the size of the buffer per each request in which the request body may be saved before it is started to be processed.

http2_chunk_size#

Syntax:

http2_chunk_size size;

Default:

http2_chunk_size 8k;

Context:

http, server, location

Sets the maximum size of chunks into which the response body is sliced. A too low value results in higher overhead. A too high value impairs prioritization due to HOL blocking.

http2_max_concurrent_pushes#

Deprecated since version 1.2.0.

Syntax:

http2_max_concurrent_pushes number;

Default:

http2_max_concurrent_pushes 10;

Context:

http, server

Limits the maximum number of concurrent push requests in a connection.

http2_max_concurrent_streams#

Syntax:

http2_max_concurrent_streams number;

Default:

http2_max_concurrent_streams 128;

Context:

http, server

Sets the maximum number of concurrent HTTP/2 streams in a connection.

http2_push#

Deprecated since version 1.2.0.

Syntax:

http2_push uri | off;

Default:

http2_push off;

Context:

http, server, location

Preemptively sends (pushes) a request to the specified uri along with the response to the original request. Only relative URIs with absolute path will be processed, for example:

http2_push /static/css/main.css;

The uri value can contain variables.

Several http2_push directives can be specified on the same configuration level. The off parameter cancels the effect of the http2_push directives inherited from the previous configuration level.

http2_push_preload#

Deprecated since version 1.2.0.

Syntax:

http2_push_preload on | off;

Default:

http2_push_preload off;

Context:

http, server, location

Enables automatic conversion of preload links specified in the “Link” response header fields into push requests.

http2_recv_buffer_size#

Syntax:

http2_recv_buffer_size size;

Default:

http2_recv_buffer_size 256k;

Context:

http

Sets the size of the per worker input buffer.

Built-in Variables#

The http_v2 module supports the following Built-in variables:

$http2#

negotiated protocol identifier:

h2

for HTTP/2 over TLS

h2c

for HTTP/2 over cleartext TCP

""

an empty string otherwise