Enabling QUIC support for OpenResty

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 sitessite1site2, which can be configured like this:

1
2
3
4
5
server {
listen 443 quic reuseport;
server_name site1.dusays.com;
# site1 的其它配置...
}

Here.443444is the UDP port for QUIC.quicSpecify the QUIC protocol.reuseportIt’s to improve performance:

1
2
3
4
5
server {
listen 444 quic reuseport;
server_name site2.dusays.com;
# site2 的其它配置...
}

port multiplexing

If a server contains multiple websites, and one of them adds thereuseportparameter, then other sites cannot add thereuseportParameters:

1
2
3
4
5
server {
listen 443 quic reuseport;
server_name site1.dusays.com;
# site1 的 QUIC 加密和伪装配置...
}

Multiple Additionsreuseportparameter will prompt a port conflict, then you can remove one of thereuseportparameter, or use a different UDP port. Example:

1
2
3
4
5
server {
listen 443 quic;
server_name site2.dusays.com;
# site2 的 QUIC 加密和伪装配置...
}

test connection

Test that QUIC connections are successfully established at each site using the Support QUIC Client tool, which can help verify that the server-side configuration is correct: