This page is in English — onze technische documentatie voor ontwikkelaars en beheerders is in het Engels.

CLI Laatst gecontroleerd:

Publishing Services with the Viaalink CLI

Publish local web applications, APIs, WebSocket services, databases, and multi-port development environments through your Viaalink Relay, and choose between a web address, a TCP port and a private alias.

Overview

The Viaalink CLI (via) publishes ports on your machine through your Viaalink Relay. Your machine connects out to the Relay over one encrypted SSH connection and gets an address on your own domain — path A on Three Kinds of Connection.

There are three clients, and this page uses all three:

  • via expose — publishes a local port on your Relay, with a login in front. The easiest: one command per port, runs in the background, reconnects by itself.
  • viaalink-relay connect — the client built into the Relay program. It publishes several forwards over one connection (-F) and reconnects by itself. via expose starts this same client for you.
  • OpenSSH (ssh -R) — nothing to install; needed for a password per link. See Using standard OpenSSH.

Publishing HTTP web applications

Quick start

To publish a local development server running on port 3000:

bash

Usage follows via expose <port> [name] [options]:

  • <port>: the local port to publish (such as 3000).
  • [name]: optional name for the service. When omitted, a bare via expose 3000 is named service-3000 (also the interactive default). Used in the public address when the Relay allows requested subdomains, and used to identify the service in via expose stop <name>.
  • --auth=basic|none: login in front of the service (basic is the default).
  • --local-only: only on this machine, no public tunnel.
  • --server <relay>: publish through this enrolled Relay instead of the default.
  • --domain <host>: one of the Relay’s other domains.
  • --foreground: run the tunnel in this terminal until Ctrl+C.

These are the options via expose lists in --help; a few older spellings still work. Any other option is refused with a suggestion (Did you mean …?) and exit status 1; earlier versions ignored it.

via expose uses your default Relay (set with via relay set, see Connect to a Relay); --server <relay-name> picks another Relay you added. It starts the built-in client in the background — with automatic reconnect and a keepalive every 5 seconds — and returns.

Always use the URL it prints rather than assuming an exact hostname like service-3000.<relay-domain>: the Relay assigns the final address, and since Viaalink Relay 1.36.0 (ASUSTOR package 0.62.6) an owner can give a person’s addresses a suffix (such as service-3000-nico.relay.example.com).

By default, password protection is on (--auth=basic). The CLI prints the address and Basic auth is on for this route — show the credentials with: via expose auth; it never prints the password itself. Run via expose auth to see the username and password. Pass --auth=none to publish without a login prompt. An Open: link that signs you in appears only if you turn on the personal setting via config set preferences.show_auth_in_urls true (off by default), and only in an interactive terminal that can hide a link’s target: the password shows as dots and the login sits in the link itself. In a pipeline, a pipe or a file no login is printed. The link carries your login, so do not share it.

The connection keeps running after the command returns; stop it with via expose stop (Managing published ports). To keep it in the terminal instead, add --foreground; it then runs until you press Ctrl+C.

To ask for a name, pass it after the port: via expose 3000 myapp.

Which name you get

You can ask for a name — for example myapp, with via expose 3000 myapp, viaalink-relay connect ... -F myapp:3000 or ssh -R myapp:80:localhost:3000. Whether you get it depends on two settings on the Relay:

Relay settingWhat happens to the name you ask for
--bind-random-subdomains on (the default)Ignored: the Relay assigns a random three-letter name, and a new one on every reconnect
--bind-random-subdomains=falseKept, as long as no other device holds it; if it is taken you get a random name instead
--bind-random-subdomains=false and --force-requested-subdomains=trueKept, and if it is taken the request fails instead of falling back to a random name

So to publish at an example address like https://myapp.relay.example.com, the Relay operator turns off --bind-random-subdomains (bind-random-subdomains: false in config.yml). Always use the URL it prints: the Relay assigns the final address, and since Viaalink Relay 1.36.0 (ASUSTOR package 0.62.6) an owner can give a person’s addresses a suffix (such as myapp-nico.relay.example.com), so never assume an exact hostname.

When your Relay runs with --bind-http-auth=true (the default), you can protect a published web address with a user name and password by putting user:password@ in front of the name in an OpenSSH remote forward:

bash

The square brackets are needed: without them OpenSSH stops with Bad remote forwarding specification, because the extra : in user:password looks like another field to it. The quotes keep your shell from reading the brackets.

Visitors to https://myapp.relay.example.com are asked for the credentials before any request reaches your local application. The Relay’s welcome text repeats the address with the user name and password in it (HTTPS: https://user:SecretPass123@myapp.relay.example.com), so do not paste that output where others can read it. More options: Access Control and Security.


WebSockets

WebSockets work through a web address without extra settings. A browser opens wss://myapp.relay.example.com/..., the Relay passes the upgrade on to your local service, and the connection stays open in both directions for as long as both sides keep it open. Chat servers, live dashboards, web terminals and collaborative editors work unchanged.

Two things to know:

  • Use the same address as the page, with wss:// for an HTTPS page. The Relay does not need a separate port for WebSockets.
  • An operator who turns on --idle-connection closes any stream that stays silent for --idle-connection-timeout (default five seconds) — WebSockets and server-sent events included. It is off by default; leave it off when you publish WebSocket services, or make sure your app sends its own keepalive messages.

Which protocol

The name and port in a forward decide what the Relay makes of it. Pick by what your service speaks and who should reach it:

You publishForwardBecomesWho can reach itUse it for
A web app or API (HTTP)a name with port 80: -F myapp:3000, -R myapp:80:localhost:3000A web address, https://myapp.relay.example.comAnyone with the link, unless you add a password or IP/country rulesWebsites, APIs, webhooks, WebSockets
Any TCP service (databases, game servers, custom protocols)a port number: -F 5432:5432, -R 5432:localhost:5432A public TCP port on the Relay, relay.example.com:<port>Anyone who can reach that portServices that must be reachable without SSH, when you accept them being public
Any TCP service, privately (SSH, databases)a name with another port: -F mybox:22:localhost:22, -R mybox:22:localhost:22A private alias, mybox:22Only devices logged in to the same Relay with an approved keySSH, remote desktops and databases you do not want on the internet
  • Web address: HTTPS ends at the Relay, which gives it a certificate, a password per link and IP/country rules. Only HTTP traffic fits; port 443 is treated the same as 80.
  • Public TCP port: the Relay copies bytes and knows nothing about the protocol. Your service has to protect itself (its own password and, where possible, its own TLS). With --bind-random-ports on (the default), the port is random from --port-bind-range and reported on connect.
  • Private alias: nothing public at all. You reach it by jumping through the Relay with OpenSSH — see SSH through the Relay. Prefer this over a public TCP port for anything that is not meant for strangers.

The full table, including how the Relay decides, is on How the Relay Works.


Publishing TCP and database services

For raw TCP forwarding (databases, caches, custom protocols), use standard OpenSSH remote forwarding (ssh -R) or the built-in client with -F <remote_port>:<local_port>:

bash

Or with the built-in client, using the remote_port:local_port form:

bash

--no-auth skips any online sign-in, so your SSH key is the only credential — the right choice for your own Relay.

The Relay opens a port on its side — random when --bind-random-ports=true (the default), or the requested one when it is turned off — and reports where it is (for example relay.example.com:41285).

A public TCP port is reachable by anyone. For a database or SSH that only you should reach, publish a private alias instead (see Which protocol).


Publishing multiple services at once

To publish several web addresses and TCP ports over a single outbound connection, repeat the -F (--forward) flag for each forward:

bash

This creates:

  • a web address for web -> localhost:3000
  • a web address for api -> localhost:8080
  • relay.example.com:<port> -> localhost:5432 (TCP)

The forms -F accepts:

FormExampleMeans
name:local_portmyapp:3000Web address for localhost:3000
name:local_host:local_portmyapp:192.168.1.20:3000Web address for another machine on your network
remote_port:local_port5432:5432Public TCP port
remote_port:local_host:local_port5432:db.lan:5432Public TCP port for another machine
name:remote_port:local_host:local_portmybox:22:localhost:22Like ssh -R: a private alias when the port is not 80 or 443

You can also define forwards in the VIAALINK_RELAY_FORWARD environment variable, as a comma-separated list:

bash

Auto-reconnect and keepalive

For long-running sessions and unreliable networks, the built-in client (viaalink-relay connect, and so via expose) reconnects by itself (--reconnect, on by default) and sends a keepalive every --keepalive seconds — a whole number of seconds, default 10, and 0 turns keepalives off. Each keepalive waits --keepalive-timeout seconds (default 5) for an answer; three missed answers in a row count as a dropped connection. via expose sets the keepalive to 5 seconds.

bash

Or with environment variables:

bash

After a reconnect the client asks for every address again. With random names on, the addresses change and the new ones are printed. Timing details: How the Relay Works.


Managing published ports

via expose keeps each connection running in the background under a name — either the optional name you pass after the port, for example via expose 3000 myapp, or service-<port> when omitted (a bare via expose 3000 is named service-3000, which is also the interactive default):

bash

Using standard OpenSSH (no CLI required)

Because Viaalink Relay speaks the standard SSH remote forwarding protocol, any machine with the ssh client can publish without the Viaalink CLI:

bash

This makes Viaalink Relay usable on servers, continuous integration runners, and embedded systems where installing extra programs is not allowed. OpenSSH does not reconnect by itself; see SSH through the Relay for a ~/.ssh/config that does the rest.


Web terminal

The Viaalink CLI includes a browser-based web terminal (via terminal), powered by ttyd. You can open a shell locally with via terminal start, or publish it through your Relay with:

bash

via terminal start tunnel does the same. Started locally, the terminal listens on this machine only (127.0.0.1), so nothing else on your network can reach it; the tunnel is the way to open it from elsewhere.

via terminal works across platforms:

  • Linux: runs bash.
  • macOS: uses ttyd installed via Homebrew.
  • Windows: runs Git Bash, or PowerShell when Git Bash is missing.

Stop the terminal server at any time with via terminal stop.


Network inspector

via inspect opens the network inspector menu; via inspect start starts the inspector and via inspect stop stops it. Its proxy listens on this machine only (127.0.0.1), and its password no longer shows in the process list.


Local HTTP service

For local development workflows and integrations, via serve workspace starts the local HTTP server on port 5678:

bash

By default it listens on 127.0.0.1 only, so nothing outside this machine can reach it. To share it, publish it with via expose 5678 <name>.