Skip to main content
This guide walks through how to deploy rustunnel-server with Docker, in two scenarios: For a non-Docker, systemd-based production deployment see the self-hosting guide. For the architecture behind the server see the architecture reference.

Prerequisites

Clone the repository once:

How the Docker image works

The deploy/Dockerfile is a three-stage build:
  1. ui-builder — installs Node 20, runs next build on the dashboard UI, and produces the static export under out/.
  2. builder — compiles the Rust server. The out/ directory is copied into crates/rustunnel-server/src/dashboard/assets/ so rust-embed can bake it into the binary at compile time.
  3. runtime — minimal debian:bookworm-slim image containing only the server binary and ca-certificates.
Because both the UI and the Rust binary are built inside Docker you do not need Node.js or Rust installed on the host to build or run the image.

Scenario A — Local development

Use this when you want to run a full server stack on your laptop for testing or development.

1 — Generate a self-signed certificate

The compose file mounts this directory into the container at /certs. To use a different path, set the CERT_DIR environment variable before running compose.

2 — Build the image

The first build takes several minutes (Rust + Node.js compilation). Subsequent builds use Docker layer caching and are much faster unless Cargo.lock or package-lock.json change.

3 — Start the server

Add -d to detach:

4 — Verify it is running

5 — Connect a client

--insecure skips TLS verification. Required for self-signed certificates. Never use this flag against a production server.

6 — Stop the server

Port reference (local)

Reaching HTTP tunnel URLs locally

HTTP tunnels use subdomains (e.g. http://abc123.localhost:8080). Browsers do not resolve *.localhost by default. Two options: Option A — curl with a Host header (no setup)
Option B — wildcard DNS via dnsmasq (macOS)
Then visit http://abc123.localhost:8080 in the browser.

Scenario B — VPS production

Use this when you have a cloud server (Ubuntu 22.04 or later recommended) with a public IP address.

Assumptions

PostgreSQL is required. The server uses PostgreSQL to store API tokens and the tunnel audit log. You may run PostgreSQL on the same VPS or use a managed service (e.g. Supabase, Neon, AWS RDS, DigitalOcean Managed Databases). Set the connection URL in deploy/server.toml under [database] url.
Set up the wildcard DNS record with your DNS provider before continuing. Both edge.rustunnel.com (bare) and *.edge.rustunnel.com (wildcard) must resolve to your server IP — the wildcard is required so HTTP tunnel subdomains work.

1 — Install dependencies on the VPS

2 — Clone the repository

3 — Obtain TLS certificates

Create the Cloudflare credentials file:
Request the certificate (bare domain + wildcard):
Certbot writes the PEM files to:
Certbot installs a systemd timer for automatic renewal — no further action needed.

4 — Configure the server

Generate a strong admin token:
Edit deploy/server.toml — set at minimum:
The file is mounted read-only into the container.

5 — Grant the container access to the certificates

The container runs as a non-root user (rustunnel). Certbot sets restrictive permissions on the live/ and archive/ directories by default:
If you prefer not to relax Certbot permissions, copy the certs to a dedicated directory and set up a Certbot post-hook to refresh the copies after each renewal.

6 — Build the Docker image

7 — Start the server

The docker-compose.yml mounts:
  • ./server.toml/etc/rustunnel/server.toml (read-only)
  • /etc/letsencrypt is not mounted by default — add the line below to the server service’s volumes section before starting:

8 — Open firewall ports

Port 9090 only needs to be open if you have an external Prometheus scraper. It is safe to leave it closed if you are running Prometheus on the same host (it reaches the metrics endpoint over the Docker bridge network).

9 — Verify the deployment

10 — Connect a client

Port reference (production)


Optional: monitoring stack (Prometheus + Grafana)

Both compose files expose the metrics endpoint to the rustunnel Docker network. The Prometheus service in docker-compose.yml scrapes it automatically.
To change the Grafana admin password before starting, set the environment variable:

Useful make targets


Updating

Pull the latest code and rebuild:
The --force-recreate flag restarts the container with the new image while leaving the rustunnel-data volume (SQLite captured-request data) intact. PostgreSQL data lives outside the container and is unaffected by container updates.

Troubleshooting

Container exits immediately

Common causes:
  • Config not mounted — ensure deploy/server.toml exists and the volume path is correct.
  • Cert files not readable — check permissions on /etc/letsencrypt/ (see step 5).
  • Port already in use — check ss -tlnp | grep -E '80|443|4040|8443'.

Dashboard shows “dashboard assets not found”

The dashboard assets were not embedded at compile time. This happens if you built the Rust binary before running npm run build (or outside Docker). Rebuild the image with docker build — the multi-stage Dockerfile handles the UI build automatically.

--insecure flag required even in production

This means the client is connecting to a server with a self-signed cert. Verify that the cert paths in server.toml point to the Let’s Encrypt PEM files and that those files are accessible inside the container.

Prometheus shows no data

Check that deploy/prometheus.yml targets rustunnel-server:9090 and that both services are on the same Docker network (rustunnel). The metrics endpoint is not exposed on the host by default — Prometheus reaches it over the bridge network.

Self-hosting

Deploy the server without Docker, using systemd, on a production VPS.

Architecture

The control plane, data plane, and subsystems running inside the container.

Client guide

Configure the rustunnel CLI to connect to your Dockerized server.

Quickstart

Open your first tunnel in under five minutes.