YAML and TOML startup configuration
File selection and precedence
Use server run --help, client --help, and client run --help from the same build to inspect its options. The client file parser handles includes and mqtt. The file key relay_endpoints maps to the repeatable --relay-alternate-endpoint option.
| Program | Default search | Explicit configuration |
|---|---|---|
| Server | app.yml in the working directory, then server.yml | server run --config PATH or TUNNEL_SERVER_CONFIG |
| Client | app.yml in the working directory, then client.yml | client --config PATH run or TUNNEL_CLIENT_CONFIG |
| Standalone SSH gateway | ssh-gateway.yml in the working directory | server serve-ssh-gateway --config PATH |
Settings use the command line, environment, configuration file, and defaults in that order. Server variables usually use TUNNEL_<UPPERCASE_KEY> and client variables usually use TUNNEL_CLIENT_<UPPERCASE_KEY>. Separate list values with commas. Run server run --help or client run --help to see the options and environment variables.
Startup files use UTF-8 .yml, .yaml, or .toml, up to 64 KiB each. Paths inside a file are relative to that file. Paths from the command line and environment are relative to the working directory.
The client can use includes: [shared.yml, local.toml] to split settings into up to 32 files, including the entry file, with up to eight levels of nesting. Declare each key once. The server reads a single file.
Data and log directories
For a SQLite server, data/ holds only state.db and its WAL, SHM, and lock files. In Docker the default is /app/data. The database holds server runtime state. MySQL and PostgreSQL servers use a dedicated database. Clients keep their identity in their own data/. Files in logs/ are disposable operational logs. SQLite servers and clients default to logs/ beside their data directory. MySQL and PostgreSQL servers default to logs/ beside the executable. If the log path resolves inside the SQLite data directory or to the directory itself, the server logs to the console only. Docker file logs default to /app/logs. Temporary backup files and restore checkpoints live in a separate backups/ directory. The default is beside the active SQLite data directory or beside the executable for MySQL and PostgreSQL. In a container the default is /app/backups. Set TUNNEL_BACKUP_DIR to use a separate directory. On Unix, restrict access to the server process user. Completed archives live in S3-compatible object storage.
| Directory | Command line | Environment | Configuration key |
|---|---|---|---|
| Data | --data-path | TUNNEL_DATA_PATH | data_path |
| Logs | --log-path | TUNNEL_LOG_PATH | log_path |
YAML environment variables
| Syntax | Behavior |
|---|---|
${VAR} | Read the variable. An unset variable is an error. |
${VAR:-fallback} | Use the fallback when the variable is unset or empty. |
$$ | Write a literal $. |
YAML expands variables only in string values. A placeholder can fill a client boolean or numeric field when it takes up the whole value. TOML values are literal.
Server keys
Key names match the argument IDs of server run and use underscores. For example, native_bind corresponds to --native-bind. Lists are for repeatable options. Use true or false for switches. Addresses use numeric IPs and ports, with brackets around IPv6 addresses. A dash in the tables means unset.
Data, security material and administration
| Key | Default | Meaning and limits |
|---|---|---|
database | sqlite | sqlite, postgres, or mysql. |
database_url | — | PostgreSQL or MySQL connection string. You can also provide it through TUNNEL_DATABASE_URL. |
data_path | data/ beside the executable | SQLite database files and sidecar files. |
host | — | Required. Use the gateway DNS name or IP address clients connect to. You can set it with --host or TUNNEL_HOST. |
pki | — | External PKI directory to import at first installation. Supply an initial transport token or token ring. Subsequent starts use database materials. |
managed_pki_seed | — | Pre-signed PKI directory for the first managed installation, with the public root certificate and online signing material. You can also set TUNNEL_MANAGED_PKI_SEED. Mutually exclusive with pki and the root certificate and key paths. |
root_ca_pem_path / root_ca_key_path | cert/root.pem / cert/root.key in the working directory | ML-DSA-87 root certificate and matching private key for issuing or rotating the managed Tunnel CA. Correspond to ROOT_CA_PEM_PATH / ROOT_CA_KEY_PATH and conflict with pki and managed_pki_seed. |
device_key_secret_file | — | Optional device wrapping key file for first installation. The server generates the key if omitted and uses the database copy thereafter. Environment variable TUNNEL_DEVICE_KEY_SECRET_FILE. |
transport_token_file | — | Initial fixed transport token file for importing external PKI. |
transport_token_ring_file | — | Initial transport token ring for importing external PKI. Mutually exclusive with the fixed token. |
admin_password | — | Initial administrator password, 12–256 bytes. Used at first startup with an empty database. Corresponds to --admin-password and TUNNEL_INIT_ADMIN_PASSWORD. |
admin_password_file | — | Regular UTF-8 file used only when the accounts table is empty. It may end in one LF or CRLF. Corresponds to --admin-password-file and TUNNEL_ADMIN_PASSWORD_FILE. |
admin | 0.0.0.0:9650 | TCP serves cleartext management HTTP. UDP is dedicated to device enrollment over PQC HTTP/3. |
log_level | info | Select debug, info, warn, or error. Environment variable TUNNEL_LOG_LEVEL. |
log_path | logs/ | Directory for log files. SQLite defaults to a location beside the data directory. MySQL and PostgreSQL default to a location beside the executable. |
flow_batch_devices | 256 | Number of device, credential and mapping combinations scanned per batch, 1–1024. |
Manual platform rotation requires a signed-in system administrator. Certificate rotation
Use the runtime environment variable TUNNEL_PKI_SUCCESSOR_DIR to select an offline-issued successor CA. Set TUNNEL_NOTIFICATION_KEYRING_FILE to import a notification keyring on first installation. Subsequent starts use the registered keys from the database. Certificate operations
Device and application listeners
| Key | Default | Meaning and limits |
|---|---|---|
gateway | 0.0.0.0:9653 | Visitor WSS and TCP/TLS over TCP. QUIC and XTCP probe over UDP. |
control | 0.0.0.0:9651 | TCP control listener for native mutual TLS, WSS, and WS with inner mutual TLS. It verifies device certificates and transport tokens. |
relay | 0.0.0.0:9652 | Work relay. TCP/TLS, WS with inner TLS, and WSS on TCP. QUIC on UDP. |
mqtt_profiles | — | Optional initial MQTT relay file. Set with --mqtt-profiles or TUNNEL_MQTT_PROFILES. The server imports it when MQTT settings are initialized and loads the database on later starts. Create and manage console-controlled relays under Resources → MQTT Relays. Server MQTT settings |
device_web / device_web_host | — | Shared mutual-TLS web listener for control, relay and access, paired with its one allowed DNS name or IP. Set both fields together. |
quic_relay | Same as relay | Override the QUIC relay UDP address. |
kcp_relay | 0.0.0.0:9654 | KCP relay UDP address. |
tcp_relay / ws_tls_relay | — | Dedicated TCP/TLS work relay, or WebSocket work relay with mutual TLS inside. |
p2p_probe | Shares gateway UDP by default | Set a separate XTCP UDP listener. The advertised address uses the gateway hostname and the probe listener's port. |
http_proxy / https_proxy | — | Dedicated WS or HTTPS SNI passthrough listener. |
https_terminate | — | Dedicated WSS listener. Configure business certificates under Domains and Certificates. |
public_listen_always | false | Bind configured public listeners even when no corresponding route is enabled. |
public_trusted_proxy_ip / native_trusted_proxy_ip | [] | Lists of trusted upstream proxy IPs for public and native TCP ingress respectively. |
native_bind | 0.0.0.0 | IP used to bind registered native TCP and UDP ports when their mappings take effect. |
native_max_ports_per_provider | 0 | Maximum active native mappings per provider. Use 0 for no per-provider limit. |
ssh_gateway_listen | — | Reserves the listener port for a separate SSH gateway on the same host. Environment variable TUNNEL_SSH_GATEWAY_LISTEN. |
Work relay tuning
Enter milliseconds for keys ending in _ms and seconds for keys ending in _secs. The defaults below are the raw values to use in configuration files.
| Key | Default | Meaning and limits |
|---|---|---|
relay_handshake_timeout_ms / relay_ticket_timeout_ms | 5000 / 8000 | The dedicated relay handshake and work-ticket binding default to 5 and 8 seconds respectively. Each accepts 100–30,000 ms. |
relay_tcp_keepalive_secs | 0 | TCP idle seconds before keepalive. 0 disables it or set 5–600. |
relay_quic_idle_timeout_secs | 300 | QUIC idle timeout, 10–900 seconds. |
relay_quic_keepalive_secs | 0 | Disabled by default on the server. A nonzero value must be below the local QUIC idle timeout. |
relay_quic_max_streams | 256 | Maximum incoming bidirectional streams per QUIC work connection, 1–256. |
relay_kcp_mtu | 1200 | KCP MTU, 576–1,400 bytes. |
relay_kcp_idle_timeout_secs | 300 | KCP idle timeout, 10–900 seconds. |
Metrics, OIDC and hooks
| Key | Default | Meaning and limits |
|---|---|---|
metrics | — | Dedicated Prometheus listener. Requires a token file and TLS for non-loopback addresses. |
metrics_token_file | — | Bearer token for metrics. Use 32 random bytes encoded as unpadded Base64URL. |
metrics_tls_cert / metrics_tls_key | — | ML-DSA-87 PEM chain and matching private key. Configure both and enable metrics. A scraper needs a trusted chain and support for TLS 1.3, pure MLKEM1024, and TLS_AES_256_GCM_SHA384. Scraper setup |
oidc_server_file | — | OIDC policy for control and access listeners. Environment variable TUNNEL_OIDC_SERVER_FILE. |
device_login_hook / control_heartbeat_hook / work_connection_hook | [] | Lists of hook addresses for device login, control heartbeats and work connections. |
new_proxy_hook / close_proxy_hook / new_user_connection_hook | [] | Lists of hook addresses for creating or changing mappings, closing mappings and admitting new application connections. |
<hook>_timeout_ms / <hook>_max_inflight | 1000 / 32 | Append these suffixes to any full hook key above. The corresponding hook is required. Each chain allows 25–5,000 ms and 1–256 in-flight calls. |
Each hook category can use up to four distinct HTTP endpoints with fixed nonzero loopback ports. Hooks run in declaration order. Assign dedicated listener ports according to deployment topology and keep them out of any native port ranges. See the full server reference for environment variables, separate maintenance commands and supplementary policy files. Server configuration · Server startup arguments
Client keys
A native client needs endpoint, web_endpoint, and client_key. For initial deployment, set root to enroll with a locally generated private key, or configure certificate, certificate_key, and tunnel_ca from the ZIP. MQTT clients use the certificates and configuration from the ZIP. Client identity · MQTT access
Connection, identity and proxies
| Key | Default | Meaning and limits |
|---|---|---|
includes | [] | Array of additional paths. Each file is decoded according to its extension. |
endpoint | — | Control endpoint containing the scheme, host, and port. |
root | — | Public ML-DSA-87 root certificate for initial native enrollment. Use --root or TUNNEL_CLIENT_ROOT. This mode enrolls using the root certificate and enrollment key. |
mqtt | — | Broker, topics, and gateway certificate name for MQTT. Use app.yml from the certificate ZIP. |
control_heartbeat_secs | 10 | Client heartbeat interval, 1–300 seconds. A device can reconnect after missing its negotiated liveness window. |
certificate | — | Client certificate chain client.pem from the ZIP. |
certificate_key | — | Client private key client.key from the ZIP. |
tunnel_ca | — | Tunnel CA certificate tunnel-ca.pem from the ZIP. |
web_ca | Depends on identity source | CA PEM file used to verify the gateway certificate. This file takes precedence when configured. The default comes from root for root enrollment, or the stored and locally configured Tunnel CA for pre-issued ZIPs. Environment variable TUNNEL_CLIENT_WEB_CA. Tunnel CA rotation |
data_path | data/ next to the executable | Client data directory, including the runtime identity. |
client_key | — | Console-issued client key. Use TUNNEL_CLIENT_KEY. |
web_endpoint | — | Gateway HTTPS origin for direct HTTP/3, such as https://api.tunnel.example.com:9650. The implicit port is 9650/UDP. |
source_ip | — | Local bind IP for outgoing server connections. |
dns_server | — | Custom DNS resolver as IP:port. |
upstream_proxy | — | HTTP CONNECT or SOCKS5 proxy URL without credentials. Mutually exclusive with upstream_proxy_file. |
upstream_proxy_file | — | Regular UTF-8 file containing the proxy URL, up to 2,050 bytes. Use this field for credentials. |
use_environment_proxy | false | Allow the dialer to consult proxy environment variables when no explicit proxy is configured. |
log_level / log_path | info / logs/ next to the data directory | Client log level and file log directory. |
MQTT file fields
| Key | Purpose |
|---|---|
mqtt.server_name | DNS name or IP matching the tunnel gateway certificate SAN. |
mqtt.topics.namespace / mqtt.topics.device | Topic namespace and device identifier, each 1–80 ASCII letters, digits, hyphens, or underscores. |
mqtt.broker.host / mqtt.broker.port / mqtt.broker.client_id | Broker hostname or IP, nonzero TLS port, and MQTT Client ID. The deployment archive sets these required file fields. |
mqtt.broker.ca_pem | Required ML-DSA-87 CA file for the broker. Relative paths resolve from the file containing the mqtt block. |
mqtt.broker.username / mqtt.broker.password_file / mqtt.broker.password | For password authentication, set the username and choose either a password file or an inline password. |
mqtt.broker.client_cert_pem / mqtt.broker.client_key_pem | Matching ML-DSA-87 certificate chain and private key when the broker requires mutual TLS. |
Work relays
Enter milliseconds for keys ending in _ms and seconds for keys ending in _secs. The defaults below use the units expected by the configuration.
| Key | Default | Meaning and limits |
|---|---|---|
relay_endpoint | Prefer KCP at 9654/UDP on the control host | Primary provider relay. Automatic selection can use an authenticated relay on 9652/TCP. Set kcp://, wss://, ws://, tls://, or quic:// to choose explicitly. |
relay_endpoints | [] | Additional relay URLs with one address per protocol. CLI equivalent --relay-alternate-endpoint. |
relay_pool_size | 0 | Prebuilt work connections, 0–8. A nonzero value requires a default relay. |
relay_multiplex / relay_compression | false / false | Enable multiplexing or compression. Both require a default relay. |
relay_dial_timeout_ms | 10000 | Overall dial deadline for an authenticated work relay. Defaults to 10 seconds and accepts 100–30,000 ms. |
relay_pool_idle_ms | 3000 | Idle pooled connections stay open for 3 seconds by default. The range is 1,000–30,000 ms. |
relay_pool_refill_ms | 500 | Refill interval and retry delay, 100–10,000 ms and below the pool idle time. |
relay_yamux_max_streams | 32 | Total streams opened per Yamux carrier, 1–32. |
relay_tcp_keepalive_secs | 0 | 0 disables TCP keepalive or set 5–600 seconds. |
relay_quic_idle_timeout_secs | 300 | QUIC idle timeout, 10–900 seconds. |
relay_quic_keepalive_secs | min(15, idle − 1) | Default adapts to local QUIC idle timeout. 0 disables keepalive. A nonzero value must be below the local idle timeout. |
relay_kcp_mtu | 1200 | KCP MTU, 576–1,400 bytes. |
relay_kcp_idle_timeout_secs | 300 | KCP idle timeout, 10–900 seconds. |
When either proxy source is provided explicitly as a CLI flag, it overrides proxy settings from the file. Use client --config PATH verify to check startup settings and any existing local identity offline. For local operations, use client --data-path PATH status, client --data-path PATH reload, or client --data-path PATH stop. Client configuration · Client CLI source
Start with YAML or TOML
These examples set the same client relay. Full startup configuration
YAML
relay_endpoint: "kcp://api.tunnel.example.com:9654"
relay_pool_size: 2TOML
relay_endpoint = "kcp://api.tunnel.example.com:9654"
relay_pool_size = 2Command reference
| Command | Purpose |
|---|---|
server --config ./server.yml run | Start the gateway and its configured listeners. |
server init-pki-root --output ./offline-root | Built-in offline ML-DSA-87 root CA command. The installation guide uses OpenSSL to generate the root CA. |
server init-pki --pki ./pki --offline-root ./offline-root | Issue the first online Tunnel CA from the existing offline root. |
server issue-pki-successor --offline-root ./offline-root --output ./pki-successor | Issue the successor Tunnel CA from the offline root. |
server export-openapi | Print the management API definition for the current binary. |
client --config ./client.yml run / verify | Start the client or check its configuration and existing local identity offline. |
client --config ./client.yml status / reload / stop | Read JSON status, reload connection settings, or stop the local process. Use the running instance’s configuration or data directory to locate it. |
See the operations guides for database inspection, object storage restore, certificate renewal, and controlled recovery. Backup and database tools · Operations
Standalone SSH gateway policy file
serve-ssh-gateway --config loads a local authorization policy, defaulting to ssh-gateway.yml. You can explicitly select either YAML or TOML. The managed policy mode starts with --managed-host-key, --managed-forward-bind, --managed-forward-ports and database flags. The local policy file is used in local policy mode.
| Field | Meaning and limits |
|---|---|
host_key | Unencrypted OpenSSH Ed25519 host key. Relative paths use the policy file directory. The private key may be up to 16 KiB. On Unix, deny access to group and other users. |
users | Up to 256 local authorization entries. |
users[].username | Unique name of 1–64 ASCII letters, digits, underscores, hyphens or dots. |
users[].public_keys | 1–16 OpenSSH Ed25519 public keys per user. A key may occur only once in the entire file. |
users[].listen | 0–16 allowed reverse listeners per user. Use numeric IPs and nonzero ports, with a unique owner for each address. Avoid collisions with the gateway listener and same-port IPv4 wildcard listeners. |
The policy file may be up to 256 KiB. Limit each public key and listen address to the services that need it. The standalone gateway adjusts sessions when it reloads the authorization policy. SSH gateway source