Zudoku
Example apps

Remote Desktops: noVNC

Remote desktops put a full Linux GUI behind a browser tab, which powers agentic computer-use workloads, secure browsing sessions, and disposable workstations. They are memory-hungry and used in short, interactive bursts, so each desktop runs in its own instance that scales to zero between sessions.

This guide explains how to create and deploy a noVNC app, allowing you to access remote desktops through a web interface inside a modern browser.

Note: Anthropic's Computer Use Demo inspired this example.

To run this example, follow these steps:

  1. Install the unikraft CLI. You need a BuildKit builder. The easiest way to get one is via Docker. Alternatively, you can also directly set up and use BuildKit, see the quick start.

  2. Clone the examples repository and cd into the examples/novnc-browser directory:

    TerminalCode
    git clone https://github.com/unikraft-cloud/examples cd examples/novnc-browser/

Make sure to log into Unikraft Cloud and pick a metro close to you. This guide uses fra (Frankfurt, 🇩🇪):

TerminalCode
unikraft login

When done, invoke the following command to deploy this app on Unikraft Cloud:

TerminalCode
unikraft build . --output <my-org>/novnc-browser:latest unikraft run --metro fra \ -m 4G \ -p 443:6080/tls+http \ -e NOVNC_PASSWORD=<my-password> \ --scale-to-zero policy=on,cooldown-time=4000,stateful=true \ --image <my-org>/novnc-browser:latest

Replace <my-password> with a long random password. For more information, see Authentication.

The output shows the instance address and other details:

TerminalCode
metro: fra name: vnc-browser uuid: 90a59b05-0ae1-4ca6-8383-79c5115355ee state: starting image: <my-org>/novnc-browser runtime: env: NOVNC_PASSWORD: * resources: memory: 4096MiB vcpus: 1 service: uuid: aaf03f7c-65e6-5624-d5f4-84e87450beee name: weathered-fog-y5jjmwfd domains: - fqdn: weathered-fog-y5jjmwfd.fra.unikraft.app networks: - uuid: 61708609-d291-572d-4a4c-399413238199 private-ip: 10.0.0.49 mac: 12:b0:1e:47:6c:59 timestamps: created: just now

In this case, the instance name is vnc-browser and the address is https://weathered-fog-y5jjmwfd.fra.unikraft.app. The name was preset, but the address is different for each run. Enter the provided address into your browser of choice to access the remote desktop interface. The browser asks for a user name and a password. Use the user name novnc and the password from NOVNC_PASSWORD.

You can list information about the instance by running:

TerminalCode
unikraft instances list
TerminalCode
METRO NAME STATE IMAGE ARGS MEMORY VCPUS FQDN CREATED fra vnc-browser standby <my-org>/novnc-browser 4.0GiB 1 weathered-fog-y5jjmwfd.fra.unikraft.app 2 minutes ago

When done, you can remove the instance:

TerminalCode
unikraft instances delete vnc-browser

Authentication

When you set the NOVNC_PASSWORD environment variable, each request to the remote desktop must have one of these credentials:

  • HTTP Basic Auth with the user name and the password. The browser shows a login dialog.
  • The query parameter token=<password>, for a link that opens the desktop without a login dialog.
  • The session cookie, which the browser gets after a login with token.

Unikraft Cloud encrypts the connection with TLS.

VariableValueDefault
NOVNC_PASSWORDPassword for the remote desktopNo authentication
NOVNC_USERUser name for HTTP Basic Auth, without a :novnc

If NOVNC_PASSWORD is set but empty, the desktop does not start. The same applies to an empty NOVNC_USER when the desktop has a password.

If you do not set NOVNC_PASSWORD, the remote desktop has no authentication. A person who knows the address can control the desktop. The instance log then shows WARNING: noVNC has no authentication.

A program, for example an AI agent, can also use the desktop. It can send the Authorization: Basic <base64 of user:password> header with each request, also with the WebSocket request to /websockify. For example:

TerminalCode
curl -u 'novnc:<my-password>' https://weathered-fog-y5jjmwfd.fra.unikraft.app/vnc.html

With Playwright, set the credentials on the browser context:

Code
context = browser.new_context( http_credentials={"username": "novnc", "password": "<my-password>"})

To open the desktop with a link, put the URL-encoded password in the token parameter:

Code
https://weathered-fog-y5jjmwfd.fra.unikraft.app/?token=<my-password>&autoconnect=true

The desktop then sets a session cookie and sends the browser to the same address without token. Thus, the password does not stay in the address bar. The browser history can keep the link with the password, so do not open the link on a shared computer. The link needs HTTPS, because the browser keeps the session cookie only on a secure connection.

In the token parameter, a + is a space, and a &, % or # breaks the link. To URL-encode the password, run this command and type the password:

TerminalCode
python3 -c 'import getpass, urllib.parse; print(urllib.parse.quote(getpass.getpass(), safe=""))'

An agent can also connect to the WebSocket with the token: wss://weathered-fog-y5jjmwfd.fra.unikraft.app/websockify?token=<my-password>.

The password in a token parameter is in the address of the first request. Proxies can write this address to their logs.

A page of another site can show the desktop in a frame. Put vnc.html and the token in the address of the frame:

Code
<iframe src="https://weathered-fog-y5jjmwfd.fra.unikraft.app/vnc.html?token=<my-password>&autoconnect=true&resize=scale"></iframe>

In a frame, the address keeps the token. The page that shows the frame contains the password, thus show this page only to persons who can know the password. Without the token in the address of the frame, a page of another site cannot show the desktop in a frame. A page of another site cannot connect to the WebSocket of the desktop.

Do not put the credentials in the address as https://user:password@.... Some browsers do not send them with the WebSocket request.

Learn more

Use the --help option for detailed information on using Unikraft Cloud:

TerminalCode
unikraft --help

Or visit the CLI Reference.

Last modified on