We are pleased to announce this early alpha version of the
HTTP/2 module for NGINX.
NGINX would like to thank Dropbox
and Automattic , who are heavy users
of our software and graciously co-sponsored the development
of our HTTP/2 implementation.
We are working on improving HTTP/2 support with the goal of
integrating it soon to the main NGINX codebase. Expect frequent
updates to this development, and please report your experiences
to the NGINX development mailing list nginx-devel@nginx.org
(check http://mailman.nginx.org/mailman/listinfo/nginx-devel).
The HTTP/2 module is currently distributed as a patch for
the NGINX 1.9.x mainline version. The patch is at an early
alpha level of quality and should not be used in production.
Please always check CHANGES.txt before applying and deploying
a new version of the HTTP/2 patch. It can contain important
information and additional steps required to migrate from the
previous versions of patch.
This patch replaces the SPDY module in NGINX.
Configuration and installation instructions are below.
How to build NGINX with HTTP/2:
1. Install OpenSSL 1.0.2+. This is required because the HTTP/2
module uses the Application-Layer Protocol Negotiation (ALPN)
TLS extension.
2. Download the NGINX 1.9.x tar-gzip package. Either visit
http://nginx.org/en/download.html, or run:
$ wget http://nginx.org/download/nginx-1.9.4.tar.gz
3. Unpack the tar-gzip package:
$ tar xvfz nginx-1.9.4.tar.gz
$ cd nginx-1.9.4
4. Download and apply the HTTP/2 module patch from
http://nginx.org/patches/http2/:
$ wget http://nginx.org/patches/http2/patch.http2.txt
$ patch -p1 < patch.http2.txt
5. Configure the NGINX build:
If you are building NGINX with OpenSSL from sources and
statically linking to it:
$ ./configure --with-http_ssl_module \
--with-http_v2_module \
--with-debug \
--with-openssl=/path/to/openssl-1.0.2
If OpenSSL is installed as an optional library
(e.g., on OS X):
$ ./configure --with-http_ssl_module \
--with-http_v2_module \
--with-debug \
--with-cc-opt=-I/opt/local/include \
--with-ld-opt=-L/opt/local/lib
6. Build NGINX:
$ make
To enable HTTP/2 in your existing HTTPS configuration,
just add the "http2" parameter to the “listen” directive:
server {
listen 443 default_server ssl http2;
ssl_certificate server.crt;
ssl_certificate_key server.key;
...
}
Optional HTTP/2 configuration directives:
- http2_recv_buffer_size (http)
specifies the size of input buffer per worker
(256k by default).
- http2_max_concurrent_streams (http, server)
sets the maximum number of concurrent HTTP/2 streams
in a single connection (128 by default).
- http2_streams_index_size (http, server)
configures the size of the HTTP/2 stream ID index;
must be a power of 2 (default is 32).
- http2_recv_timeout (http, server)
defines the timeout when expecting more data from
the client (default is 30s).
- http2_idle_timeout (http, server)
sets the inactivity timeout after which the connection
is closed (default is 3m).
- http2_chunk_size (http, server, location)
defines the default DATA frames size for response body
(default is 8k).
- http2_max_field_size (http, server)
limits the maximum size of a request header field
(default is 4k).
- http2_max_header_size (http, server)
limits the maximum size of headers in a request
(default is 16k).
The default values are more or less optimized for generic use,
so there's normally no need to tweak them.
HTTP/2 variable:
- $http2
negotiated protocol identifier if the request came
via HTTP/2 ("h2", "h2c"), or empty value.
Disclaimer: use this code at your own risk. It is distributed
under the 2-clause BSD-like license, and NGINX, Inc. is not
responsible for any negative effects that the usage of this
code might cause.
--
NGINX, Inc., http://nginx.com