tree: 00f4628ae256fadca66c79a512da7cd6944c5029 [search]
  1. include/
  2. quic/
  3. config2.m4
  4. h3_callbacks.c
  5. h3_config.c
  6. h3_filter.c
  7. h3_hooks.c
  8. h3_io.c
  9. h3_request.c
  10. h3_server.c
  11. h3_session.c
  12. h3_socket.c
  13. h3_socket_bpf.c
  14. h3_socket_os.c
  15. h3_stream.c
  16. h3_threads.c
  17. Makefile.in
  18. mod_http3.c
  19. QUIC_CONNECTION_MIGRATION.md
  20. README.md
modules/http3/README.md

mod_http3: HTTP/3 & QUIC for Apache HTTP Server

mod_http3 adds support for the HTTP/3 protocol (RFC 9114) running over the QUIC transport protocol (RFC 9000) to the Apache HTTP Server.

HTTP/3 runs over UDP rather than TCP and integrates TLS 1.3 encryption natively inside QUIC, eliminating TCP head-of-line blocking and providing faster connection establishment (0-RTT / 1-RTT).

Experimental Notice: mod_http3 is currently experimental and intended for testing and development. Do not use it in production yet.


Architecture & Dependencies

mod_http3 relies on:

  1. libnghttp3 (>= 1.0.0): Handles HTTP/3 framing and QPACK header compression (RFC 9204).
  2. ngtcp2 (>= 1.22.1) with its OpenSSL crypto helper (libngtcp2_crypto_ossl): Handles the QUIC transport.
  3. OpenSSL (>= 3.5): Handles the TLS 1.3 handshake. With --with-http3-quic=openssl, it also handles the QUIC transport and ngtcp2 is not needed.

Build Instructions

Prerequisites

Install OpenSSL, libnghttp3 and libngtcp2 with libngtcp2_crypto_ossl.

Configuration

To build mod_http3, add --enable-http3 to your httpd ./configure command:

./configure --enable-ssl --enable-http2 --enable-http3 [other options...]

If libnghttp3 or libngtcp2 is installed in a non-standard location:

./configure --enable-http3 --with-nghttp3=/path/to/nghttp3 --with-ngtcp2=/path/to/ngtcp2 [other options...]

If pkg-config is available on your system, libnghttp3.pc will be automatically detected via PKG_CONFIG_PATH.


Basic Configuration

1. Enable Modules and Protocols

To enable HTTP/3 alongside HTTP/2 and HTTP/1.1:

LoadModule ssl_module   modules/mod_ssl.so
LoadModule http3_module modules/mod_http3.so

# Listen on both TCP (for HTTPS/Alt-Svc) and UDP (for QUIC)
Listen 4433 https

<VirtualHost *:4433>
    ServerName example.com

    SSLEngine on
    SSLCertificateFile    conf/server.crt
    SSLCertificateKeyFile conf/server.key

    # Enable HTTP/3, HTTP/2, and HTTP/1.1
    Protocols h3 h2 http/1.1

    DocumentRoot /var/www/html

</VirtualHost>

2. Client Discovery via Alt-Svc

Because HTTP/3 runs over UDP, web browsers typically connect via TCP (HTTP/1.1 or HTTP/2) first. mod_http3 automatically injects the Alt-Svc header into responses:

Alt-Svc: h3=":4433"; ma=86400; persist=1

Browsers caching this header will switch to HTTP/3 over QUIC on subsequent requests.


Configuration Directives

DirectiveDefaultContextDescription
H3PortServer Portserver config, virtual hostUDP port to listen on for QUIC/HTTP-3.
H3AltSvconserver config, virtual hostAdvertise HTTP/3 support via the Alt-Svc response header.
H3AltSvcMaxAge86400server config, virtual hostmax-age in seconds for the Alt-Svc header advertisement.
H3MaxConnections256server configMaximum concurrent QUIC/HTTP-3 connections per child process.
H3MaxConcurrentStreams100server config, virtual hostMaximum concurrent active streams per connection.
H3StreamBufferSize65536server config, virtual hostPer-stream request and streaming-response buffer size (bytes).
H3MaxRequestBodySize10485760 (10MB)server config, virtual hostMaximum request body size buffered in memory (bytes).
H3MaxResponseBodySize0 (unlimited)server config, virtual hostMaximum response body size for whole-response buffering.
H3HandshakeTimeout10server configTimeout in seconds for QUIC TLS handshakes.
H3IdleTimeout300server configIdle timeout in seconds before closing inactive QUIC connections.
H3StreamTimeoutServer Timeoutserver config, virtual hostTimeout in seconds without progress before aborting a stream.
H3AddressValidationonserver configValidate client addresses using QUIC Retry packets before accept.
H3SessionTicketsonserver configIssue TLS 1.3 session tickets for 0-RTT/fast connection resumption.
H3SocketBufferSize2097152 (2MB)server configSocket send and receive buffer sizes for the UDP listener.
H3MaxStreamErrors8server config, virtual hostStream errors allowed before terminating connection with H3_EXCESSIVE_LOAD.
H3QpackTableCapacity4096server config, virtual hostQPACK dynamic table capacity in bytes (0 disables dynamic table).
H3QpackBlockedStreams0server config, virtual hostAllowed QPACK blocked streams count.
H3MinWorkers16server configMinimum request worker threads per child process.
H3MaxWorkers64server configMaximum request worker threads per child process.
H3MaxWorkerIdleSeconds600server configSeconds an idle worker thread is kept before termination.

Status Handler

You can inspect HTTP/3 runtime status by enabling the http3-status handler:

<Location /http3-status>
    SetHandler http3-status
    Require local
</Location>

Testing & Verification

Using curl (with HTTP/3 support)

# Direct HTTP/3 connection
curl --http3 -v https://localhost:4433/

# Test Alt-Svc upgrade
curl --alt-svc /tmp/altsvc.cache -v https://localhost:4433/

Using Web Browsers

  • Google Chrome: Launch with --origin-to-force-quic-on=localhost:4433 or ensure valid certificates and reload after receiving the Alt-Svc header.
  • Mozilla Firefox: Enable HTTP/3 in about:config (network.http.http3.enable = true).

Current Limitations & Notes

  • Multi-Process UDP Listener: On Linux, the parent binds the UDP port before the privilege drop. Without ListenCoresBucketsRatio, one child serves the port. With it, each child serves one SO_REUSEPORT socket per listener bucket. On other platforms, one child binds the port.
  • Connection Migration: The ngtcp2 transport supports QUIC connection migration (RFC 9000 ยง9); the OpenSSL transport does not. With more than one QUIC socket, migration needs eBPF routing by connection ID (see QUIC_CONNECTION_MIGRATION.md).
  • TLS Certificates: Modern browsers reject self-signed or invalid certificates for HTTP/3 more strictly than for HTTP/1.1 or HTTP/2. Use trusted certificates or valid local CA certificates during testing.

Choosing the QUIC transport (--with-http3-quic)

Measured with h3bench (openssl-h3-examples), one run per transport on the same machine, so only compare numbers from the same run:

  • Idle connections: ngtcp2 holds 4000 idle connections with no errors at about 50% CPU. openssl uses about 4 times the CPU at 1000 connections, gets errors at 2000 and none connect at 4000.
  • Loaded, 1 to 32 connections: openssl serves about 30 to 60% more requests per second, with lower p50 and p99 latency (for example 32 connections of 32 streams: 875 against 577 rps, p50 1.5 s against 2.3 s).
  • One connection, one request at a time (1x1): ngtcp2 answers in about 1 ms. openssl stalls (0.2 rps, p50 over 1 s); the cause is not found yet.
  • Not the transport: both servers sit near 2000% CPU in every loaded case, even 1x1, so something outside the QUIC layer, probably the event loop or the worker threads, uses CPU it should not. Look at that before reading much into the throughput gap.
  • Features: only ngtcp2 has 0-RTT, routing by connection ID across child processes and connection migration.

Use ngtcp2 (the default) unless you need to avoid the ngtcp2 dependency.