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.
SSH tunnel
Section titled “SSH tunnel”An SSH tunnel does not change localspace. The browser on your computer connects to the dashboard as if it ran there.
-
On your computer, run:
Terminal window ssh -L 7090:127.0.0.1:7090 devbox -
In that SSH session, run
lo ui code. Copy the address that starts withhttp://127.0.0.1:7090/. -
Open the address in the browser on your computer.
Reverse proxy
Section titled “Reverse proxy”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.
-
Start the reverse proxy. Examples follow this procedure.
-
Add the host name of the proxy to
config.yaml:~/.localspace/config.yaml ui:hosts: [devbox.example.ts.net] -
Stop
lo ui serveand start it again, so it reads the setting. -
On the machine that runs localspace, run
lo ui code. It prints an address such ashttps://devbox.example.ts.net/#code=<code>. -
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
Section titled “Tailscale”Tailscale Serve makes the dashboard available to the devices of your tailnet only, with HTTPS:
tailscale serve --bg 7090The host name is the name of the machine in your tailnet, such as devbox.example.ts.net.
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.
Rules of the sign-in
Section titled “Rules of the sign-in”- The token in
ui.tokensigns in only on this machine. A request that comes through a reverse proxy cannot use it. lo ui codegives a code that works one time, for 5 minutes. Onlyloon 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 sessionslists 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 rotatereplaces the token and signs out all browsers.