Nginx 1.25.0启用HTTP3支持


模块 ngx_http_v3_module提供实验性 HTTP/3 支持:默认情况下不构建此模块,应使用 --with-http_v3_module 配置参数启用它。


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 {
        # 为了更好的兼容性,建议
        # 对 http/3 和 https 使用相同的端口
        listen 8443 quic reuseport;
        listen 8443 ssl;

        ssl_certificate     certs/example.com.crt;
        ssl_certificate_key certs/example.com.key;

        location / {
            # 宣传 HTTP/3 
            add_header Alt-Svc 'h3=
":8443"; ma=86400';
        }
    }
}

请注意,通过 TLS 接受 HTTP/3 连接需要 TLSv1.3 协议支持,该协议自 OpenSSL 1.1.1 版起可用。

更多见模块 ngx_http_v3_module