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 函式庫(例如 BoringSSLLibreSSLQuicTLS)來建置和執行此模組。否則,當使用 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 on | off;
預設
http3 on;
上下文 http, server

啟用 HTTP/3 協定協商。

語法 http3_hq on | off;
預設
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 on | off;
預設
quic_bpf off;
上下文

啟用使用 eBPF 的 QUIC 封包路由。啟用後,這允許支援 QUIC 連線移轉。

此指令僅在 Linux 5.7+ 上受支援。

語法 quic_gso on | off;
預設
quic_gso off;
上下文 http, server

啟用使用分段卸載的最佳化批次模式傳送。

最佳化傳送僅在具有 UDP_SEGMENT 的 Linux 上受支援。

語法 quic_host_key 檔案;
預設
上下文 http, server

設定包含用於加密無狀態重設和位址驗證權杖的密鑰的檔案。預設情況下,每次重新載入時都會產生隨機金鑰。不接受使用舊金鑰產生的權杖。

語法 quic_retry on | off;
預設
quic_retry off;
上下文 http, server

啟用 QUIC 位址驗證功能。這包括在 Retry 封包或 NEW_TOKEN 框架中傳送新的權杖,以及驗證在 Initial 封包中接收到的權杖。

內嵌變數

ngx_http_v3_module 模組支援以下內嵌變數

$http3
協商的協定識別碼:HTTP/3 連線為 “h3”,hq 連線為 “hq”,否則為空字串。