HTTP/2 Fully Supported in NGINX Plus | NGINX

Original: https://www.nginx.com/blog/http2-r7/

Earlier this week we released NGINX Plus Release 7 (R7) with support for HTTP/2. As the latest standard for the HTTP protocol, HTTP/2 is designed to bring increased performance and security to modern web applications.

The HTTP/2 implementation in NGINX Plus works seamlessly with existing sites and applications. Minimal changes are required, as NGINX Plus delivers HTTP/1.x and HTTP/2 traffic in parallel for the best experience, no matter what browser your users choose.

[In NGINX Plus R7] HTTP/2 support is available in the optional nginx‑plus‑http2 package only. The nginx‑plus and nginx‑plus‑extras packages provide SPDY support and are currently recommended for production sites because of wider browser support and code maturity.

Editor – In NGINX Plus R11 and later, HTTP/2 is supported in the nginx-plus package, the nginx-plus-extras package is deprecated in favor of dynamic modules, and SPDY is not supported.

In NGINX Plus R8 through R10, HTTP/2 is supported in the nginx-plus and nginx-plus-extras packages, SPDY is not supported, and there is no separate nginx‑plus‑http2 package.

For an overview of NGINX Plus R7, see Announcing NGINX Plus R7 on our blog.

For detailed discussions of other new features in NGINX Plus R7, see these related blog posts:

Why Move to HTTP/2?

HTTP/2 makes data transfer more efficient and more secure for your applications. HTTP/2 adds five key features that improve performance when compared to HTTP/1.x:

To learn more about HTTP/2:

How NGINX Plus Implements HTTP/2

Our implementation of HTTP/2 is based on our support for SPDY, which is widely deployed (nearly 75% of websites that use SPDY use NGINX or NGINX Plus). With NGINX Plus, you can deploy HTTP/2 with very little change to your application infrastructure. This section discusses how NGINX  lus implements support for HTTP/2.

An HTTP/2 Gateway

http2-27

NGINX Plus acts an HTTP/2 gateway. It talks HTTP/2 to client web browsers that support it, but translates HTTP/2 requests back to HTTP/1.x (or FastCGI, SCGI, uWSGI, etc. – whatever protocol you are currently using) for communication with backend servers.

Backward Compatibility

http2-28

For the foreseeable future you’ll need to support HTTP/2 and HTTP/1.x side by side. As of this writing, over 50% of users already run a web browser that supports HTTP/2, but this also means almost 50% don’t.

To support both HTTP/1.x and HTTP/2 side by side, NGINX Plus implements the Next Protocol Negotiation (NPN) extension to TLS. When a web browser connects to a server, it sends a list of supported protocols to the server. If the browser includes h2 – that is, HTTP/2 – in the list of supported protocols, NGINX Plus uses HTTP/2 for connections to that browser. If the browser doesn’t implement NPN, or doesn’t send h2 in its list of supported protocols, NGINX Plus falls back to HTTP/1.x.

Moving to HTTP/2

NGINX, Inc. aims to make the transition to HTTP/2 as seamless as possible. This section goes through the changes that need to be made to enable HTTP/2 for your applications, which include just a few changes to the configuration of NGINX Plus.

Prerequisites

Upgrade to the NGINX Plus R7 nginx‑plus‑http2 package. Note that an HTTP/2‑enabled version of the nginx‑plus‑extras package is not available at this time.

Redirecting All Traffic to SSL/TLS

If your app is not already encrypted with SSL/TLS, now would be a good time to make that move. Encrypting your app protects you from spying as well as from man‑in‑the‑middle attacks. Some search engines even reward encrypted sites with improved rankings in search results. The following configuration block redirects all plain HTTP requests to the encrypted version of the site.

server {
    listen 80;
    location / {
        return 301 https://$host$request_uri;
    }
}

Enabling HTTP/2

To enable HTTP/2 support, simply add the http2 parameter to all listen directives. Also include the ssl parameter, required because browsers do not support HTTP/2 without encryption.

server {
    listen 443 ssl http2 default_server;

    ssl_certificate     server.crt;
    ssl_certificate_key server.key;
    …
}

If necessary, restart NGINX \ Plus, for example by running the nginx -s reload command. To verify that HTTP/2 translation is working, you can use the “HTTP/2 and SPDY indicator” plug-in available for Google Chrome and the “HTTP/2 indicator” for Firefox.

Caveats

Try out HTTP/2 support in NGINX Plus for yourself –start your free 30‑day trial today or contact us for a live demo.

Special Thanks

NGINX, Inc. would like to thank Dropbox and Automattic, who are heavy users of our software and graciously cosponsored the development of our HTTP/2 implementation. Their contributions have helped accelerate our ability to bring this software to you, and we hope you are able to support them in turn.

Retrieved by Nick Shadrin from nginx.com website.