Skip to content

Reach the dashboard from a different machine

lo ui serve listens on 127.0.0.1 only, so only the machine that runs it can open the dashboard. This guide shows two methods to open it from a different computer. The first method is an SSH tunnel. The second method is a reverse proxy, such as Tailscale Serve, Caddy or nginx.

An SSH tunnel does not change localspace. The browser on your computer connects to the dashboard as if it ran there.

  1. On your computer, run:

    Terminal window
    ssh -L 7090:127.0.0.1:7090 devbox
  2. In that SSH session, run lo ui code. Copy the address that starts with http://127.0.0.1:7090/.

  3. Open the address in the browser on your computer.

A reverse proxy listens on the network, gives the dashboard a host name and HTTPS, and sends the requests to 127.0.0.1:7090. The dashboard refuses a request with a host name that it does not know. Thus you must add the host name of the proxy to ui.hosts.

  1. Start the reverse proxy. Examples follow this procedure.

  2. Add the host name of the proxy to config.yaml:

    ~/.localspace/config.yaml
    ui:
    hosts: [devbox.example.ts.net]
  3. Stop lo ui serve and start it again, so it reads the setting.

  4. On the machine that runs localspace, run lo ui code. It prints an address such as https://devbox.example.ts.net/#code=<code>.

  5. Open the address in the browser of the other computer before 5 minutes go by. The code works one time.

If the page shows host <name> is not this dashboard, the proxy sends a different host name. Add that name to ui.hosts.

Tailscale Serve makes the dashboard available to the devices of your tailnet only, with HTTPS:

Terminal window
tailscale serve --bg 7090

The host name is the name of the machine in your tailnet, such as devbox.example.ts.net.

Caddyfile
devbox.example.com {
reverse_proxy 127.0.0.1:7090
}

Caddy sends the host name and the scheme to the dashboard. Add authentication in Caddy, for example basic_auth, if the proxy is on a network that other people use.

server {
listen 443 ssl;
server_name devbox.example.com;
location / {
proxy_pass http://127.0.0.1:7090;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

The Upgrade and Connection headers are necessary for the terminals of the dashboard.

  • The token in ui.token signs in only on this machine. A request that comes through a reverse proxy cannot use it.
  • lo ui code gives a code that works one time, for 5 minutes. Only lo on this machine can get a code.
  • A session stays valid for 30 days after its last use.
  • When the browser reaches the proxy with HTTPS, the session cookie is Secure. The browser does not send it over plain HTTP.
  • lo ui sessions lists the sessions. lo ui sessions rm <id> signs out one browser, and closes its open terminals and log streams immediately. To sign in again, the browser must have a new code.
  • lo ui token rotate replaces the token and signs out all browsers.