Agent commands
tunl connects to a local port. It does not start the server. The server is on its own page.
Commands
| Command | What it does |
|---|---|
tunl http <port> | HTTP, HTTP/2 (h2c / gRPC), and WebSocket tunnel. A flag may be written before the port or after it. |
tunl tcp <port> | Raw TCP tunnel (optional upstream HAProxy --proxy-proto v1|v2). |
tunl tls <port> | TLS passthrough. The bytes are forwarded without being cut. |
tunl udp <port> | UDP datagram tunnel (session NAT table, reserved UDP port support). |
tunl start [name ...] | Opens the tunnels in tunl.yml in one process. If names are given, only those keys open. |
tunl config check | Checks the configuration without running it. config edit opens the file. Writes a sample if the file is missing. The editor is EDITOR on Windows, or Notepad if that is unset; on Linux and macOS it is VISUAL, then EDITOR, or vi if neither is set. |
tunl completion powershell|bash|zsh | Prints a shell completion script. Subcommand, flag, the --config file, and the --account account are completed. Install is below. |
tunl service install | Installs a Windows service and asks for an administrator. service uninstall removes it, service start and service stop start and stop it. --name is for more than one service on the same machine. The service account is --account system|virtual|localservice|networkservice (default system). |
tunl version | Prints the version. |
tunl update --url | Updates the agent from the panel's server. A server on another machine needs https://; detail below. |
http, tcp, and tls flags
| Flag | Environment | Default | Meaning |
|---|---|---|---|
--server | ADIT_SERVER | 127.0.0.1:7000 | Control address. If the server was started with --control-tls, tls://host:port |
--fingerprint | ADIT_FINGERPRINT | empty | sha256:... fingerprint of a self-signed server certificate. Only with a tls:// address |
--allow-plain | ADIT_ALLOW_PLAIN | off | Allows a connection to a server on another machine without tls://; the token goes over the network in the clear. Without it, the agent does not make that connection. Not required for 127.0.0.1, localhost, and ::1 |
--name | empty | Reserved name. Empty means a temporary name | |
--token | ADIT_TOKEN | empty | Server token |
--auth | empty | user:password | |
--host | 127.0.0.1 | Left side of the local address when only a port is given | |
--allow | empty | Allowed IP or CIDR. Repeatable. A comma splits too | |
--rate | 0 | Requests per minute per client. 0 is unlimited | |
--add | empty | Request header Name:value. HTTP only | |
--remove | empty | Request header to delete. HTTP only | |
--deny | empty | Rejected IP or CIDR. Repeatable. Does not pass even if it is inside allow | |
--response-add | empty | Response header Name:value. HTTP only | |
--response-remove | empty | Response header to delete. HTTP only | |
--verify-webhook | empty | github:secret, slack:secret, stripe:secret, or hmac-sha256:Header:secret. HTTP only | |
--host-header | empty | Host header sent to the local app: rewrite (use upstream address) or explicit host[:port]. HTTP only | |
--route | empty | Path-prefix routing /prefix=target (port, host:port, https://, or file://). Repeatable. HTTP only | |
--domain | empty | Bind verified custom hostname(s) to this tunnel. Repeatable | |
--pool | off | Allow multiple agents to share the same --name endpoint pool | |
--lb | round-robin | Pool load-balancing strategy: round-robin, least-conn, ip-hash, or failover | |
--weight | 1 | Replica weight (1..100) for weighted round-robin | |
--drain-timeout | 5s | Graceful drain window on Ctrl+C / SIGTERM before closing in-flight streams | |
--proxy-proto | empty | Prepend HAProxy PROXY protocol header (v1 or v2) to local TCP/TLS upstream connections | |
--http2 | off | Force end-to-end HTTP/2 (h2c / ALPN h2) for HTTP and gRPC upstreams | |
--api-key | empty | Require constant-time edge API key (secret or Header:secret); stripped before upstream. Repeatable | |
--jwt-secret / --jwt-jwks-url | empty | Verify Bearer JWT at the edge via HMAC secret or SSRF-guarded HTTPS JWKS (RS*, ES*, EdDSA); pair with --jwt-iss / --jwt-aud | |
--oauth | empty | Edge OIDC/OAuth2 PKCE login (oidc, google, github); pair with --oauth-allow-email / --oauth-allow-domain | |
--cors | empty | Edge CORS policy (* or comma-separated origins; answers OPTIONS preflight with 204) | |
--max-body | 0 | Maximum request body size (e.g. 10m, 512k); oversize requests receive 413 | |
--mock | empty | Answer directly at the edge without dialing upstream (e.g. 200:{"ok":true}) | |
--waf | off | Linear-time edge WAF blocking path traversal, sensitive dotfiles, SQLi, XSS, and Log4Shell | |
--event-webhook | empty | HTTPS webhook notified on tunnel up/down, pool failover, and quota events | |
--inspect | 127.0.0.1:4040 | Local inspector. off turns it off |
The target may be a port, http://host:port, https://host:port, or a file:// path. http:// translates to plain TCP. On an HTTPS upstream the certificate is not verified; that is for a development certificate. A file target serves that folder over HTTP. A TCP or TLS tunnel accepts only host:port.
While a tunnel is open, each request is one line in the terminal: tunnel name, method, path, status, and duration. The panel record is separate. By default the agent serves recent requests at 127.0.0.1:4040. If you start a second agent on the same machine, that port is taken; the agent takes the first free port from 4041 through 4050 and prints the address. An address you set with --inspect is not moved; if it is busy, the agent stops and says denetçi açılamadı. The browser opens the page. /api/requests returns the record list, and /api/tunnels returns the open tunnels. When the same tunnel reconnects, it appears once in the list. Turn it off with --inspect off. While the inspector listens on a loopback address, it answers only requests whose Host is localhost or a loopback IP (such as 127.0.0.1 or ::1); another Host gets 403. That stops a site from pointing its own name at 127.0.0.1 and reading the inspector from your browser (DNS rebinding). If you bound the inspector to a non-loopback address with --inspect, this check is not done.
Other commands
tunl tls 4430
tunl http 3000 --route /api=8080 --route /static=file:///var/www --host-header rewrite
tunl http 3000 --deny 203.0.113.8 --response-add X-Out:tunl --verify-webhook hmac-sha256:X-Signature:secret
tunl config check
tunl completion powershell
tunl service install --config tunl.yml
tls forwards the bytes without cutting them (on both a dedicated port and the shared HTTPS port via SNI). --route splits one HTTP tunnel across multiple local services or folders by longest path prefix. --host-header rewrite rewrites the Host header to each matched upstream's address while preserving X-Forwarded-Host. --deny turns away the addresses on the list. --response-add and --response-remove change a response header. --verify-webhook cuts a request whose GitHub, Slack, Stripe, or generic HMAC-SHA256 signature does not match, with 403. config check checks the file without running it and reports whether the connection is encrypted. service install installs a Windows service and asks for an administrator; the service runs tunl start --config, and its output goes to tunl-service.log next to the configuration file. The service runs as LocalSystem by default; --account virtual uses an unprivileged account that belongs to that service and grants write permission on the configuration folder. If the configuration is in your user folder (C:\Users\you), that account cannot read it; the install warns, so move the file somewhere like C:\ProgramData\tunl.surf.
tunl http 3000
tunl http 3000 --name demo --server 127.0.0.1:7000
tunl http 8080 --auth user:password
tunl tcp 5432
start flags
| Flag | Default | Meaning |
|---|---|---|
--config | tunl.yml | Configuration file |
--server | from the file | Replaces the file's control address |
--token | from the file | Replaces the file's token |
--fingerprint | from the file | Replaces the file's fingerprint field |
--inspect | 127.0.0.1:4040 | Local inspector. off turns it off |
ADIT_SERVER, ADIT_TOKEN, and ADIT_FINGERPRINT also override the file. ADIT_ALLOW_PLAIN or --allow-plain allows a clear connection the way allow_plain: true in the file does; none of them takes the permission back. tunl config check reports whether the agent will connect to this server. Names are keys in the file: tunl start web opens only that tunnel. Flags may also be written after the names: tunl start web --config tunl.yml. tunl start --inspect off turns the local inspector off. This command does not take a port. If the token sits in the file and (on Linux and macOS) other users can read the file, the agent says so; run chmod 600 tunl.yml, or put the token in ADIT_TOKEN instead of the file. On Windows the permission bits mean nothing, so this warning is not printed.
Shell completion
| Shell | Run once | Add to the startup file |
|---|---|---|
| PowerShell | $PROFILE: tunl completion powershell | Out-String | Invoke-Expression | |
| bash | tunl completion bash > ~/.tunl-completion.bash | ~/.bashrc (on macOS, ~/.bash_profile): . ~/.tunl-completion.bash |
| zsh | mkdir -p ~/.zfunc && tunl completion zsh > ~/.zfunc/_tunl | ~/.zshrc: fpath=(~/.zfunc $fpath), then autoload -Uz compinit && compinit |
In zsh the fpath line must come before the compinit line. If you source the script before compinit is loaded, it tells you what to do and does not install completion. A file whose name contains a space comes back quoted in PowerShell and escaped in bash and zsh; that includes the bash 3.2 that ships with macOS. A flag is not suggested after a flag that expects a value. Windows PowerShell does not consult completion at all while only -- is being typed; type tunl http and press Tab and every flag is listed.
update
tunl update --url http://127.0.0.1:4590
If --url is not given, ADIT_URL is used, or http://127.0.0.1:4590 if that is unset too.
The downloaded program runs with the privileges of the person who updates (system privileges if the service is LocalSystem). The checksum comes from the same server as the program, so it only shows that the file was not corrupted; it is not a signature. Over clear http://, someone on the network can change both together. Because of that:
- An
https://address is always accepted;http://only for127.0.0.1,localhost, and::1. - A clear server on another machine needs
--allow-plain(ADIT_ALLOW_PLAIN); the agent prints a warning on every run. - If an
https://address redirects you to anhttp://address, the update stops. - The download list may be at most 1 MB and the program at most 256 MB; a response over the limit is rejected and no temporary file is left.