On this page
  1. Client environment variables
  2. Client configuration file
  3. Server
    1. How the server reads its configuration
    2. Server reference

Configuration

Client environment variables

Variable Meaning
TUNNEX_TOKEN API token. Takes precedence over the one stored by tunnex login; use it in containers and CI.
TUNNEX_SERVER Server to connect to, e.g. wss://connect.example.com (default: wss://connect.tunnex.org). Same as --server.
TUNNEX_HOME Directory for the profile and the local request store (default ~/.tunnex; /data in the client image).
TUNNEX_CONFIG Path of the file tunnex start reads (default tunnex.yaml).
TUNNEX_INSPECTOR_PORT Local inspector port (default 4040; the next free port is used if it is busy).
TUNNEX_INSPECTOR_HOST Inspector bind address (default 127.0.0.1; 0.0.0.0 in the client image — publish the port to localhost only).
TUNNEX_INSPECTOR_HOSTS Extra Host header values the inspector accepts, comma-separated (e.g. tunnex:4040 inside a Compose network).
TUNNEX_NO_INSPECTOR 1 disables the inspector.
TUNNEX_LOGIN_TOKEN tunnex login stores this token instead of opening the browser.
TUNNEX_INBOX_SECRET Signing secret for tunnex inboxes create, so it does not end up in shell history.
TUNNEX_LOG_LEVEL Python log level of the client (WARNING by default).

Precedence: command-line option > environment > stored profile > default. In tunnex start, inspector values written in tunnex.yaml win over TUNNEX_INSPECTOR_*, and the file's server: wins over TUNNEX_SERVER.

Client configuration file

tunnex start runs every tunnel and listener of a YAML file — the entry point of the client image. tunnex start --check validates the file without connecting.

version: 1
server: ${TUNNEX_SERVER:-wss://connect.tunnex.org}   # optional
inspector:
  enabled: true
  host: 0.0.0.0          # values set here win over TUNNEX_INSPECTOR_HOST / _PORT
  port: 4040
  hosts: ["tunnex:4040"]

tunnels:
  web:
    addr: app:3000                     # port, host:port or URL (http/https, with a base path)
    proto: http                        # http | tcp
    subdomain: acme-preview            # needs an account; reserved automatically
    basic_auth: ["demo:${DEMO_PASSWORD}"]
    keys: []                           # API keys callers must send (Bearer or X-Api-Key)
    allow_ips: ["203.0.113.0/24"]
    allow_emails: ["@example.com"]     # Tunnex SSO (needs GitHub sign-in on the server)
    allow_paths: ["/api/"]
    rate_limit: 600                    # requests per minute at the edge
    host_header: rewrite               # rewrite | preserve | <value>
    inspect: true                      # record traffic in the local inspector

listeners:
  stripe:
    inbox: acme-stripe                 # or a list of inboxes
    forward: http://app:3000           # the event path is appended
    filters: ["json.livemode=false"]
    from: cursor                       # cursor | now | 30m / 6h / 2d | <event id>
    name: staging                      # subscription name (default: <hostname>-<key>)
    host_header: rewrite
    inspect: true
  • ${VAR} and ${VAR:-default} are replaced from the environment; a missing variable without a default is an error. Numbers may be written unquoted.
  • Unknown keys are errors, so typos fail fast.
  • A token: key is rejected: tokens come from TUNNEX_TOKEN only.
  • Filters and from are explained in Inboxes.

Server

How the server reads its configuration

  1. A YAML file at TUNNEX_CONFIG (the server image ships one with server.bind: 0.0.0.0).
  2. Environment variables override the file: every key as TUNNEX_<SECTION>__<KEY> (double underscore, e.g. TUNNEX_WEBHOOKS__MAX_BODY_BYTES=2097152, TUNNEX_LIMITS__FREE__CONCURRENT_TUNNELS=20), plus the short aliases below. List values are comma-separated.
  3. Unknown keys are errors; the server refuses to start and lists every problem.

Secrets (TUNNEX_SECRET_KEY, the database password, the GitHub client secret) belong in the environment, never in the file.

Alias Key
TUNNEX_SECRET_KEY auth.secret_key
TUNNEX_DATABASE_URL database.url
TUNNEX_DOMAIN server.domain
TUNNEX_CONTROL_HOST server.control_host
TUNNEX_PUBLIC_SCHEME / TUNNEX_PUBLIC_PORT server.public_scheme / server.public_port
TUNNEX_HTTP_PORT server.http_port
TUNNEX_BIND server.bind
TUNNEX_GITHUB_CLIENT_ID / _SECRET auth.github.client_id / client_secret
TUNNEX_METRICS_PORT metrics.port
TUNNEX_LOG_LEVEL / TUNNEX_LOG_FORMAT logging.level / logging.format

Configuration files written for earlier releases are accepted: database.path, server.host, tcp_udp and the ssl/client sections are translated or ignored.

Server reference

server

Key Default Meaning
domain tunnex.org Tunnels and inboxes are served at <subdomain>.<domain>.
control_host connect.<domain> Console, API and the client endpoint.
bind / http_port 127.0.0.1 / 8081 The HTTP listener. Put a TLS-terminating reverse proxy with a wildcard certificate in front.
public_scheme https Scheme in generated URLs. With http (local development) a missing secret key is generated per start.
public_port — Port in generated URLs when clients reach the server on a non-default port (8081 in the local examples).
reserved_subdomains www, api, admin, … Names nobody can take.
trusted_proxies 127.0.0.1, ::1 Only these peers may set X-Forwarded-For/X-Real-IP; anything else is replaced.
response_timeout 300 Seconds to wait for the response head from a client.
anonymous_claim_hours 24 How long a random subdomain stays with the anonymous machine that used it.
abuse_email abuse@<domain> Shown on the browser warning page of anonymous tunnels.
max_streams_per_tunnel 256 Concurrent requests/connections per tunnel; more get 503.
handshakes_per_minute 30 Client connections per minute per IP.
drain_seconds 10 Graceful shutdown: how long in-flight requests may finish before clients get GOAWAY.

tcp

Key Default Meaning
enabled true Raw TCP tunnels (accounts only).
bind 0.0.0.0 Interface for public TCP ports.
port_min / port_max 45000 / 46000 Port range to open in the firewall; port_min: 0 picks any free port (development).

database

Key Default Meaning
url sqlite+aiosqlite:///./data/server.db Use PostgreSQL in production: postgresql+asyncpg://user:pass@host/db. Migrations run at start.
pool_size 10 Connection pool size.
request_log_retention_days 7 Retention of the per-request log behind usage charts.
echo false Log SQL (debugging).

auth

Key Default Meaning
secret_key — Required over HTTPS. Signs sessions and links, and derives the key that encrypts inbox secrets — changing it invalidates both. Generate with openssl rand -base64 48.
signup_enabled true Allow new accounts.
anonymous_tunnels true Allow tunnels without an account. Set to false on private servers: clients get login_required.
session_days 30 Console session lifetime.
github.client_id / client_secret — "Sign in with GitHub"; also enables email SSO for tunnels (it trusts only GitHub-verified emails). Callback: https://<control_host>/auth/github/callback.

limits

Two plans, anonymous and free (every account). Keys per plan:

Key anonymous free Meaning
requests_per_minute 120 1200 Edge rate limit per tunnel.
concurrent_tunnels 3 (per IP) 10 Tunnels and listeners open at once.
reserved_subdomains 0 3 Subdomains an account may reserve.
tcp false true Raw TCP tunnels.
sso false true Email SSO policies.
teams 3 3 Teams a user may own.

webhooks

Key Default Meaning
enabled true Inboxes.
max_body_bytes 1048576 Largest event accepted (413 above).
default_retention_days / max_retention_days 7 / 30 Retention of new inboxes, and the most an inbox may ask for.
inboxes_per_team 10
events_per_minute 600 Per inbox (429 with Retry-After above).
subscriptions_per_inbox 50 Distinct listener names per inbox.
max_catchup 1000 Most events delivered to a listener that reconnects.
delivery_timeout 30 Seconds a listener's app may take to answer a delivery.

metrics, logging

Key Default Meaning
metrics.enabled / bind / port true / 127.0.0.1 / 9101 Prometheus metrics at /metrics.
logging.level INFO DEBUG, INFO, WARNING, ERROR.
logging.format json One JSON object per line with request/inbox/event correlation fields; text for development. Secrets in headers and URLs are redacted.

A complete example: tunnex_server/config.yaml.example.

Edit this page on GitLab