vagusQUIC and WebTransport relay for services behind NAT

☰ Contents · Start › Self-hosting

Self-hosting

Deploy a vagus relay on a Linux server and attach a private service behind it. Replace relay.example.com with your own domain throughout. Assumes vagus is installed on PATH (see Install).

Requirements: a Linux server with a public IP, open UDP and HTTPS ports, and a DNS zone where you can create A, AAAA, and CAA records. The relay needs no database and stores nothing on disk besides its TLS certificate and key.

For systemd units that engram follow keeps on a release channel, and for tuning, see Operations. For an OpenTofu cloud VM walkthrough, see AWS Lightsail.

1. DNS

Create two records for the relay's IPv4 address (A) and, if available, IPv6 address (AAAA):

Name Purpose
control.relay.example.com Connectors and browsers connect here; the relay's TLS certificate covers this name
*.relay.example.com Clients reach each service at <route-id>.relay.example.com

Each service gets a unique route ID derived from its connector's identity key.

2. Get the relay certificate

Connectors verify the relay certificate against the system root store by default, so a publicly trusted certificate for control.relay.example.com avoids distributing a custom CA. With certbot and TCP port 80 open:

sudo certbot certonly --standalone -d control.relay.example.com

The relay reads its certificate at startup only. Add a certbot deploy hook to restart the relay after renewal:

sudo tee /etc/letsencrypt/renewal-hooks/deploy/vagus-relay <<'EOF'
#!/bin/sh
systemctl try-restart vagus-relay.service
EOF
sudo chmod 0755 /etc/letsencrypt/renewal-hooks/deploy/vagus-relay

Restarting sends SIGINT and drains active sessions before exiting; connectors reconnect within a few seconds.

Never use a wildcard certificate on the relay. The relay certificate must cover only the relay's own hostname; a *.relay.example.com certificate would let anyone who steals the relay key impersonate services to clients that opt out of pinning.

Pin issuance for control.relay.example.com to your ACME account with a CAA record (certbot show_account prints the account URI):

control.relay.example.com. CAA 0 issue "letsencrypt.org; accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/123456789"

Put this CAA record on control.relay.example.com, not on relay.example.com, so it does not restrict service hostnames under the zone.

3. Open firewall ports

Port Protocol Source Purpose
443 UDP Any Public client QUIC (-public)
19451 UDP Connectors Connector control links (-control)
80 TCP Any (during renewal) certbot HTTP-01 challenge
443 TCP Any HTTPS (-https): route statements, plus admission and handoff if enabled

With ufw:

sudo ufw allow 443/udp
sudo ufw allow 19451/udp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp

Any connector reaching -control can register its own route ID. It cannot hijack your route without your identity key, but it can consume relay slots and bandwidth. For a private relay, restrict UDP 19451 to your connectors' IPs:

sudo ufw allow from 203.0.113.7 to any port 19451 proto udp

4. Start the relay

Raise kernel UDP buffer caps on Linux (sudo sysctl -w net.core.rmem_max=7500000 net.core.wmem_max=7500000, see Operations), set GOMEMLIMIT to the memory available to the relay, and start vagus relay:

GOMEMLIMIT=160MiB vagus relay \
  -public 0.0.0.0:443 \
  -control 0.0.0.0:19451 \
  -https 0.0.0.0:443 \
  -domain relay.example.com \
  -cert /etc/letsencrypt/live/control.relay.example.com/fullchain.pem \
  -key /etc/letsencrypt/live/control.relay.example.com/privkey.pem

Add -allow-origins for browser admission or -native-handoff for native handoff. For production supervision with LoadCredential and graceful SIGINT drains, install the systemd unit in Operations.

Run in a container

Release container images are published to ghcr.io/neuroplastio/vagus for Linux amd64 and arm64 (static binary on distroless, UID/GID 65532) with build provenance attestations (gh attestation verify oci://ghcr.io/neuroplastio/vagus:latest --repo neuroplastio/vagus). Copy examples/compose/docker-compose.yaml, make the certificate and key readable by UID 65532, and start the relay:

export RELAY_DOMAIN=relay.example.com
export CONTROL_CERT=/etc/letsencrypt/live/control.relay.example.com/fullchain.pem
export CONTROL_KEY=/etc/letsencrypt/live/control.relay.example.com/privkey.pem
docker compose up -d relay

5. Attach a service

On the service host (no open inbound ports required), generate an Ed25519 identity key once:

sudo install -d -m 0700 /etc/vagus
id=$(sudo vagus keygen -out /etc/vagus/endpoint.pem)
echo "$id.relay.example.com"

Back up /etc/vagus/endpoint.pem and keep it private. This key defines the route ID and signs the service's leaf certificates and statements. If it leaks, generate a new key and switch to the new route ID.

Start the connector forwarding to your local QUIC backend:

vagus connect \
  -relay control.relay.example.com:19451 \
  -identity /etc/vagus/endpoint.pem \
  -backend 127.0.0.1:4443 \
  -leaf-dir /var/lib/vagus

Wait for admitted <route-id> on stderr. The connector writes the active leaf certificate and key (cert.pem, key.pem) into -leaf-dir, rotating them automatically. Configure your service to serve cert.pem and key.pem and reload when cert.pem changes. The relay never sees these keys.

For a systemd service unit, see Operations. To embed the connector directly inside a Go service instead of running a sidecar, see Go integration.

6. Verify

Check that the relay serves the route's statement over HTTPS:

curl -fsS "https://control.relay.example.com/v1/statements/$id" | wc -c

To test end-to-end QUIC routing with the echo example from a checkout, run go run ./examples/quic-echo serve -listen 127.0.0.1:4443 -leaf-dir /var/lib/vagus on the service host and dial from another machine:

go run ./examples/quic-echo dial -via "$id.relay.example.com:443" -name "$id.relay.example.com" hello

It prints hello after verifying the service's leaf certificate against $id. If dialing times out, verify that the connector logged admitted, UDP 443 reaches the relay, $id.relay.example.com resolves to the relay, and the client sends that SNI without ECH.

Next steps

  • AWS Lightsail: provision a small dual-stack VM with OpenTofu, static IP, firewall rules, and first-boot setup.
  • Operations: systemd units, limits, GOMEMLIMIT, failover, and incident recovery.
  • Browser admission: restrict routing to allowed web origins with single-use tickets and optional Turnstile verification.
  • Security and threat model: trust boundaries, key roles, and threat analysis.

Starting the terminal…