QUIC is a UDP-based transport layer protocol proposed by Google to reduce handshake delays and enable fast connection establishment, multiplexing, and connection migration. This tutorial shares how to enable QUIC support in OpenResty.
preliminary
Ensure that OpenResty has been successfully installed. if you see the OpenResty welcome page, the installation was successful.
OpenResty supports QUIC by integrating with Nginx and taking advantage of its modularity. you need to enable QUIC support in the Nginx configuration file. This usually involves configuring to listen on UDP ports, since QUIC runs on UDP.
OpenResty has supported QUIC since version 1.25. For previous versions, you need to compile and install the module yourself to support QUIC.
Use a QUIC-enabled client tool to test whether the QUIC connection was successfully established.
listening port
For each site, you need to configure the listening port for QUIC in the Nginx configuration file. Since QUIC runs on UDP, you need to configure a directive for each site to listen on the UDP port. For example, if there are two sitessite1
和site2
, which can be configured like this:
1 |
server { |
Here.443
和444
is the UDP port for QUIC.quic
Specify the QUIC protocol.reuseport
It’s to improve performance:
1 |
server { |
port multiplexing
If a server contains multiple websites, and one of them adds thereuseport
parameter, then other sites cannot add thereuseport
Parameters:
1 |
server { |
Multiple Additionsreuseport
parameter will prompt a port conflict, then you can remove one of thereuseport
parameter, or use a different UDP port. Example:
1 |
server { |