How to enable HTTP/3 on an Nginx server

Nginx 1.25 introduced functional QUIC support, and experimental HTTP/3 support. Caddy’s had QUIC support for some time; LiteSpeed is promoting it; Docker-hosted Wiki.JS (what this site runs on) does not, as of July 2024. This quick guide assumes you were already using HTTPS on your website before; if not, you should look up Let’s Encrypt and an SSL config generator.

  1. Adjust your firewall rules on your cloud provider, firewall appliance, and/or iptables / nftables / ufw rules in Linux: you will need to open UDP 443.
  2. Update to at least Nginx 1.25, using the Nginx distribution repos.
  3. Official Nginx uses /etc/nginx/conf.d/ to look up .conf files for site definitions. If you were using non-conf files in /etc/nginx/sites-available & /etc/nginx/sites-enabled, move those over as .conf files and/or update /etc/nginx/nginx.conf to use the sites-enabled directory (the symlinks to sites-available can be moved themselves to .conf filenames).
  4. Edit your site .conf files to use the following for HTTPS:
    listen 443 quic;
    listen 443 ssl;
    http2 on;
    
  5. For each .conf file, add the following to each location section:
    add_header Alt-Svc 'h3=":443"; ma=86400';
    
  6. If using php-fpm applications, you might need to set your pools to the nginx user (though some recommend a different way to handle this).
  7. Restart Nginx and run an HTTP/3 Check against your website.