Module ngx_http_v2_module

Known Issues
Example Configuration
Directives
     http2_chunk_size
     http2_idle_timeout
     http2_max_concurrent_streams
     http2_max_field_size
     http2_max_header_size
     http2_recv_buffer_size
     http2_recv_timeout
Embedded Variables

The ngx_http_v2_module module (1.9.5) provides support for HTTP/2 and supersedes the ngx_http_spdy_module module.

This module is not built by default, it should be enabled with the --with-http_v2_module configuration parameter.

Known Issues

The module is experimental, caveat emptor applies.

Before version 1.9.14, buffering of a client request body could not be disabled regardless of proxy_request_buffering, fastcgi_request_buffering, uwsgi_request_buffering, and scgi_request_buffering directive values.

Example Configuration

server {
    listen 443 ssl http2;

    ssl_certificate server.crt;
    ssl_certificate_key server.key;
}

Note that accepting HTTP/2 connections over TLS requires the “Application-Layer Protocol Negotiation” (ALPN) TLS extension support, which is available only since OpenSSL version 1.0.2. Using the “Next Protocol Negotiation” (NPN) TLS extension for this purpose (available since OpenSSL version 1.0.1) is not guaranteed.

Also note that if the ssl_prefer_server_ciphers directive is set to the value “on”, the ciphers should be configured to comply with RFC 7540, Appendix A black list and supported by clients.

Directives

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.

Syntax: http2_idle_timeout time;
Default:
http2_idle_timeout 3m;
Context: http, server

Sets the timeout of inactivity after which the connection is closed.

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.

Syntax: http2_max_field_size size;
Default:
http2_max_field_size 4k;
Context: http, server

Limits the maximum size of an HPACK-compressed request header field. The limit applies equally to both name and value. Note that if Huffman encoding is applied, the actual size of decompressed name and value strings may be larger. For most requests, the default limit should be enough.

Syntax: http2_max_header_size size;
Default:
http2_max_header_size 16k;
Context: http, server

Limits the maximum size of the entire request header list after HPACK decompression. For most requests, the default limit should be enough.

Syntax: http2_recv_buffer_size size;
Default:
http2_recv_buffer_size 256k;
Context: http

Sets the size of the per worker input buffer.

Syntax: http2_recv_timeout time;
Default:
http2_recv_timeout 30s;
Context: http, server

Sets the timeout for expecting more data from the client, after which the connection is closed.

Embedded Variables

The ngx_http_v2_module module supports the following embedded variables:

$http2
negotiated protocol identifier: “h2” for HTTP/2 over TLS, “h2c” for HTTP/2 over cleartext TCP, or an empty string otherwise.