Guide to Optimizing Nginx Web Server Performance with HTTP/3 QUIC and BoringSSL on Ubuntu Server
A detailed guide to compiling and configuring Nginx from source with HTTP/3 QUIC support via BoringSSL on Ubuntu Server, optimizing performance, security, and compatibility with...
Image credit: geralt · Pixabay Content License
A detailed guide to compiling and configuring Nginx from source with HTTP/3 QUIC support via BoringSSL on Ubuntu Server, optimizing performance, security, and compatibility with modern networking protocols. This guide includes preparation, compilation, configuration, testing, and troubleshooting steps, along with CLI commands, parameter tables, and error-checking sections.
Introduction and Objectives
HTTP/3 is the next-generation data transfer protocol based on QUIC, which uses UDP instead of TCP to reduce latency, improve connection stability in unstable networks, and accelerate page load times. Nginx supports HTTP/3 through a user-compiled module, typically using BoringSSL—a source-available version of OpenSSL developed by Google. This guide explains how to build Nginx from source on Ubuntu Server 22.04, integrate HTTP/3 QUIC with BoringSSL, and configure it for stable, secure, and efficient operation.
Requirements and Preparation
To complete this guide, you will need:
- Ubuntu Server 22.04 (64-bit)
- Development tools: build-essential, git, curl, wget, unzip
- Support libraries: libpcre3-dev, zlib1g-dev, libssl-dev
- Required software: Nginx source code, BoringSSL, nghttp3, quiche
Run the following commands to install the necessary tools:
sudo apt update
sudo apt install -y build-essential git curl wget unzip libpcre3-dev zlib1g-dev libssl-dev
Compiling Nginx with HTTP/3 QUIC and BoringSSL
Follow these steps to compile Nginx from source with HTTP/3 support:
- Download Nginx source code (version 1.25.3 is stable at the time of writing):
cd /opt wget https://nginx.org/download/nginx-1.25.3.tar.gz tar -xzf nginx-1.25.3.tar.gz - Clone and build BoringSSL:
cd /opt git clone https://boringssl.googlesource.com/boringssl cd boringssl mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. make - Clone and build nghttp3:
cd /opt git clone https://github.com/nghttp3/nghttp3.git cd nghttp3 autoreconf -iv ./configure --enable-lib-only make - Clone and build quiche (Cloudflare’s QUIC library):
cd /opt git clone https://github.com/cloudflare/quiche.git cd quiche cargo build --release - Compile Nginx with required modules:
cd /opt/nginx-1.25.3 ./configure \ --prefix=/usr/share/nginx \ --sbin-path=/usr/sbin/nginx \ --modules-path=/usr/lib/nginx/modules \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_v3_module \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_geoip_module=dynamic \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_auth_request_module \ --with-http_secure_link_module \ --with-http_slice_module \ --with-threads \ --with-stream \ --with-stream_ssl_module \ --with-stream_ssl_preread_module \ --with-mail \ --with-mail_ssl_module \ --with-compat \ --with-file-aio \ --with-ipv6 \ --with-http_quic_module \ --with-openssl=/opt/boringssl/build \ --with-openssl-opt=enable-ec_nistp_64_gcc_128 \ --with-openssl-module=/opt/quiche/quiche-openssl make sudo make install
Configuring Nginx for HTTP/3 QUIC
After compilation, configure Nginx to enable HTTP/3 on port 443:
server {
listen 443 quic;
listen 443 ssl http2;
server_name your-domain.com;
ssl_certificate /etc/nginx/ssl/your-domain.com.crt;
ssl_certificate_key /etc/nginx/ssl/your-domain.com.key;
ssl_protocols TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
ssl_trusted_certificate /etc/nginx/ssl/your-domain.com.chain.pem;
ssl_dhparam /etc/nginx/ssl/dhparam.pem;
location / {
root /var/www/html;
index index.html;
}
}
Ensure you generate valid SSL certificates (e.g., via Let's Encrypt) and create a DH param file.
Testing and Verification
After configuration, start Nginx and verify:
sudo systemctl start nginx
sudo systemctl enable nginx
Test HTTP/3 connectivity using:
curl --http3 -I https://your-domain.com
Alternatively, use tools like quic-client or nghttp3 for QUIC connection testing.
Troubleshooting Common Issues
| Error | Causes | Solutions |
|---|---|---|
| Failed to start Nginx | Missing BoringSSL libraries or incorrect paths | Verify --with-openssl and --with-openssl-module paths |
| HTTP/3 not working | Invalid SSL certificate or port 443 blocked | Ensure port 443 is open and SSL certificates are valid |
| Compilation errors | Missing libraries or incompatible versions | Run apt update and install all required dev packages |
References
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
