Skip to content

Docker Compose deployment ​

These examples use Linux host networking and local images built from the same source revision. Use a separate directory for each role. Containers run as 10001:10001 and read /app/app.yml by default. If you download a template, set image to your locally built image. For published images, get the templates at the release tag and use the same release for both roles. Build the images · Release and build guide

Server ​

  1. Create a dedicated empty MySQL database and a user that can create tables, read, and write. Follow the quick start to generate fresh ML-DSA-87 CA material. Put root.pem, issuer.pem, and issuer.key into cert/ in the server directory. Keep the root private key offline. Generate the root CA
  2. Run the following commands in the server directory. The container user needs read access to the certificates. backups/ holds temporary job files and restore checkpoints. Completed archives live in object storage. Backup storage settings
sh
install -d -m 0755 cert
sudo install -d -m 0700 -o 10001 -g 10001 backups
sudo chmod 0644 cert/root.pem cert/issuer.pem
sudo chown 10001:10001 cert/issuer.key
sudo chmod 0600 cert/issuer.key

Save the following as docker-compose.yml in the server directory. Download the server Compose template

yaml
services:
  server:
    image: tunnel-server:main
    network_mode: host
    restart: always
    cap_drop:
      - ALL
    security_opt:
      - "no-new-privileges:true"
    environment:
      TUNNEL_HOST: "${TUNNEL_HOST:?set TUNNEL_HOST}"
      TUNNEL_DATABASE_URL:
      TUNNEL_INIT_ADMIN_PASSWORD:
      TUNNEL_MANAGED_PKI_SEED: /app/cert
    volumes:
      - ./cert:/app/cert:ro
      - ./backups:/app/backups

Create .env in the same directory. Enter the gateway DNS name or IP that clients connect to, the MySQL URL, and the initial administrator password. Percent-encode reserved URL characters in the database username or password. Set .env to mode 0600.

dotenv
TUNNEL_HOST=api.tunnel.example.com
TUNNEL_DATABASE_URL=mysql://tunnel:DB_PASSWORD@127.0.0.1:3306/tunnel
TUNNEL_INIT_ADMIN_PASSWORD=replace-with-a-strong-password
sh
docker compose config --quiet
docker compose up -d --pull never server
docker compose logs --tail 100 server

Open http://SERVER_ADDRESS:9650/ and sign in as admin. After initialization, you can remove TUNNEL_INIT_ADMIN_PASSWORD from .env. Subsequent starts use the stored password hash.

For SQLite, add TUNNEL_DATABASE: sqlite under environment, remove TUNNEL_DATABASE_URL, and add ./data:/app/data. Before starting, create the writable data/ directory owned by 10001:10001. For PostgreSQL, set TUNNEL_DATABASE: postgres and provide its connection URL. Database and directory settings

Default listeners ​

PortPurpose
9650/TCPDirect HTTP console and management API
9650/UDPDevice enrollment and transport token retrieval over PQC HTTP/3
9651/TCPControl connections
9652/TCP, 9652/UDPWork relay. TCP carries TCP/TLS, WS with inner TLS, and WSS. UDP carries QUIC
9653/TCP, 9653/UDPVisitor ingress. TCP carries TCP/TLS and WSS. UDP carries QUIC and XTCP probes
9654/UDPKCP work relay, enabled by default

The server binds to 0.0.0.0 by default. Allow 9654/UDP for remote KCP clients. With bridge networking, also publish 9654:9654/udp. Register raw TCP and UDP mapping ports under Resources → Port resources. The advertised XTCP probe address uses the gateway hostname and the probe listener's port. Optional listeners · XTCP

Client ​

  1. Add a direct client in the console, copy its registration key, and download the pre-issued certificate ZIP. Place client.pem, client.key, and tunnel-ca.pem into cert/ in the client directory. Add a client
  2. Run the following commands in the client directory. Give the container user read access to the certificates and write access to data/. Keep this directory so the client retains its device identity across container recreations.
sh
install -d -m 0755 cert
sudo install -d -m 0700 -o 10001 -g 10001 data
sudo chmod 0644 cert/client.pem cert/tunnel-ca.pem
sudo chown 10001:10001 cert/client.key
sudo chmod 0600 cert/client.key

Save the following as docker-compose.yml in the client directory. Download the client Compose template

yaml
services:
  client:
    image: tunnel-client:main
    network_mode: host
    restart: always
    cap_drop:
      - ALL
    security_opt:
      - "no-new-privileges:true"
    environment:
      TUNNEL_CLIENT_ENDPOINT:
      TUNNEL_CLIENT_WEB_ENDPOINT:
      TUNNEL_CLIENT_KEY:
    volumes:
      - ./cert:/app/cert:ro
      - ./data:/app/data

Create .env in the same directory. Set the control endpoint, the gateway’s direct HTTP/3 enrollment endpoint, and the registration key. Set .env to mode 0600.

dotenv
TUNNEL_CLIENT_ENDPOINT=tls://api.tunnel.example.com:9651
TUNNEL_CLIENT_WEB_ENDPOINT=https://api.tunnel.example.com:9650
TUNNEL_CLIENT_KEY=client-key-from-console
sh
docker compose config --quiet
docker compose up -d --pull never client
docker compose exec -T client /app/xtc status --config /app/app.yml

Optional settings ​

  • For root-based enrollment, put the trusted public root.pem into cert/ and add TUNNEL_CLIENT_ROOT: /app/cert/root.pem under environment. Client identity settings
  • For MQTT access, extract the complete certificate ZIP into a separate directory and mount it read-only, for example ./mqtt-client:/app/mqtt-client:ro. Set TUNNEL_CLIENT_CONFIG: /app/mqtt-client/app.yml, remove the three direct-access variables, and keep the data mount. Point --config to the MQTT bundle’s app.yml when checking status. MQTT access
  • To keep file logs across container recreations, create logs/ owned by 10001:10001 and add ./logs:/app/logs. For a custom startup configuration, create app.yml and mount it with ./app.yml:/app/app.yml:ro. Data and log paths · YAML and TOML

Optional HTTPS reverse proxy ​

Nginx on the same host can serve public HTTPS through the management socket. Create a dedicated run/ directory, set its owner to 10001, use a shared group accessible to Nginx workers, and set mode 2750. Add ./run:/run/xigexb-tunnel to Tunnel and it will create admin.sock. An Nginx container can mount the same directory read-only. Nginx template

Set your domain and publicly trusted certificate paths in the template and proxy through the management socket. Run nginx -t and then nginx -s reload. Devices reach the gateway’s PQC HTTP/3 enrollment listener directly, so allow 9650/UDP. Management request source · Enrollment endpoint