ngx_http_v3_module 模块
| 已知问题 示例配置 指令 http3 http3_hq http3_max_concurrent_streams http3_stream_buffer_size quic_active_connection_id_limit quic_bpf quic_gso quic_host_key quic_retry 嵌入式变量 |
ngx_http_v3_module 模块 (1.25.0) 提供了对 HTTP/3 的实验性支持。
此模块不是默认构建的,应该使用 --with-http_v3_module 配置参数启用它。
建议使用提供了 QUIC 支持的 SSL 库,如 BoringSSL、LibreSSL 或 QuicTLS 来构建和运行此模块。否则,当使用 OpenSSL 库时,将使用不支持 早期数据 的 OpenSSL 兼容层。
已知问题
此模块是实验性的,买家应谨慎购买。
示例配置
http {
log_format quic '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" "$http3"';
access_log logs/access.log quic;
server {
# for better compatibility it's recommended
# to use the same port for http/3 and https
listen 8443 quic reuseport;
listen 8443 ssl;
ssl_certificate certs/example.com.crt;
ssl_certificate_key certs/example.com.key;
location / {
# used to advertise the availability of HTTP/3
add_header Alt-Svc 'h3=":8443"; ma=86400';
}
}
}
请注意,接受 TLS 上的 HTTP/3 连接需要支持 TLSv1.3 协议,这是自 OpenSSL 版本 1.1.1 以来可用的。
指令
| 语法: | http3 |
|---|---|
| 默认: |
http3 on; |
| 上下文: | http,server |
启用 HTTP/3 协议协商。
| 语法: | http3_hq |
|---|---|
| 默认: |
http3_hq off; |
| 上下文: | http,server |
启用 QUIC 互操作性测试 中使用的 HTTP/0.9 协议协商。
| 语法: | http3_max_concurrent_streams |
|---|---|
| 默认: |
http3_max_concurrent_streams 128; |
| 上下文: | http,server |
设置连接中的最大并发 HTTP/3 请求流数。
| 语法: | http3_stream_buffer_size |
|---|---|
| 默认: |
http3_stream_buffer_size 64k; |
| 上下文: | http, server |
设置用于读取和写入QUIC流的缓冲区大小。
| 语法: | quic_active_connection_id_limit |
|---|---|
| 默认: |
quic_active_connection_id_limit 2; |
| 上下文: | http, server |
设置QUIC active_connection_id_limit 传输参数值。这是服务器上可存储的客户端连接ID的最大数量。
| 语法: | quic_bpf |
|---|---|
| 默认: |
quic_bpf off; |
| 上下文: | main |
启用使用eBPF进行QUIC数据包路由。启用后,这允许支持QUIC连接迁移。
该指令仅在Linux 5.7+上受支持。
| 语法: | quic_gso |
|---|---|
| 默认: |
quic_gso off; |
| 上下文: | http, server |
启用使用分段卸载的优化批量模式发送。
优化的发送仅在支持UDP_SEGMENT的Linux上受支持。
| 语法: | quic_host_key |
|---|---|
| 默认: | — |
| 上下文: | http, server |
设置用于加密无状态重置和地址验证令牌的密钥文件。默认情况下,每次重新加载时都会生成一个随机密钥。不接受使用旧密钥生成的令牌。
| 语法: | quic_retry |
|---|---|
| 默认: |
quic_retry off; |
| 上下文: | http, server |
启用QUIC地址验证功能。包括在Retry数据包或NEW_TOKEN帧中发送一个新令牌,并验证在Initial数据包中接收到的令牌。
嵌入变量
ngx_http_v3_module模块支持以下嵌入变量:
-
$http3 -
negotiated protocol identifier: “
h3” for HTTP/3 connections, “hq” for hq connections, or an empty string otherwise.
