Chapter 8. HTTP/2 and HTTP/3 (QUIC)
8.0 Introduction
HTTP/2 and HTTP/3 are major revisions to the HTTP protocol. Both of these updates were designed to address a performance issue known as head-of-line blocking, which causes network packets to be held up by the completion of the packet queued before them. HTTP/2 mitigated the head-of-line blocking issue for the initial TCP handshake in the application layer by enabling full request and response multiplexing over a single TCP connection. The TCP protocol itself, however, still exhibits this issue due to its packet loss recovery mechanisms, which require packets to be transmitted in order and lost packets to block and be retransmitted before proceeding. In HTTP/3, TCP was replaced with the QUIC (pronounced “quick”) protocol, which is built on top of the user datagram protocol (UDP). UDP does not require connection handshaking, transmission order, or implement packet loss recovery, allowing QUIC to solve these transport challenges in more efficient ways.
HTTP/2 also introduced compression on HTTP header fields and support for request prioritization. This chapter details the basic configuration for enabling HTTP/2 and HTTP/3 in NGINX as well as configuring Google’s open source Remote Procedure Call (gRPC).
8.1 Enabling HTTP/2
Problem
You want to take advantage of HTTP/2.
Solution
Turn on HTTP/2 on your NGINX server:
server
{
listen
443
ssl
default_server
;
http2
on
;
ssl_certificate
server
.
crt
;
ssl_certificate_key
server ...
Get NGINX Cookbook, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.