Zudoku
Plugins

noVNC plugin

1 note
  • Plugins are part of enterprise plans. Contact support to enable them for your account. support@unikraft.com.

The noVNC plugin adds a virtual desktop to an instance. You use the desktop in a browser through noVNC, and a program drives it through the plugin endpoint. The plugin brings its own root filesystem for the desktop, so the image of the instance needs no desktop software.

ImageContent
plugins/novnc:latestA desktop with a terminal, approximately 210 MiB.
plugins/novnc:firefox-latestA desktop with a terminal and the Extended Support Release of Firefox, approximately 510 MiB, for an instance with at least 2 GiB of memory.

The plugin serves the desktop on the destination port of its first plugin service:

TerminalCode
unikraft api /v1/instances --metro fra \ '{ "name": "my-desktop", "image": "official/alpine:latest", "memory_mb": 2048, "scale_to_zero": { "policy": "on", "stateful": true, "cooldown_time_ms": 5000 }, "plugins": [ { "name": "novnc", "image": "plugins/novnc:firefox-latest", "config": { "password": "<a long random password>", "width": 1280, "height": 800 }, "services": [ { "port": 443, "destination_port": 6080, "handlers": ["tls", "http"] } ] } ] }'

Open https://novnc-<uuid>.api.fra.unikraft.cloud/ in a browser, and log in with the user novnc and the password of the configuration. With stateful scale-to-zero, the instance sleeps while nobody uses the desktop, and wakes with its windows still open.

Always set a password. Without one, anyone who knows the address can control the desktop.

The plugin takes these keys in config, all optional:

KeyDefaultDescription
passwordNonePassword of the desktop, without which the desktop has no authentication
usernovncUser name for HTTP basic authentication, without a :
width, height1024, 768Initial size of the screen, at most 2560 × 1600
host_viewfalsetrue shows the files and mounts of the instance in the desktop, and runs the desktop programs as root
launchersNonePanel buttons, each with a name, an exec command, and an optional icon
autostartNoneShell commands that the desktop starts when it's ready

The desktop accepts the password in these ways:

MethodUse
HTTP basic authentication with user and passwordThe login dialog of the browser, or a program, for example curl -u 'novnc:<password>'
The token query parameterA link that opens the desktop without a login dialog, a WebSocket to /websockify, or a frame on a page of another site
A session cookieA browser after it opens a link with token, until the desktop restarts

For example, this link opens the desktop:

Code
https://novnc-<uuid>.api.fra.unikraft.cloud/?token=<URL-encoded password>&autoconnect=true

In a browser, the plugin then sets a session cookie, and removes the token from the address. The first address still contains the password, so the browser history and the logs of a proxy can keep it. Treat a link with token like the password.

A page of another site can show the desktop in a frame only with the token in the address of the frame, for example vnc.html?token=<URL-encoded password>&autoconnect=true. Thus, that page contains the password.

A program drives the desktop through the plugin endpoint, /v1/instances/<uuid>/plugins/novnc. The API reference describes each request. Positions are in pixels from the top-left corner of the screen:

RequestBodyDescription
GET /screenNoneReturns the width and height of the screen.
PUT /screen{"width": 1280, "height": 800}Resizes the screen, and keeps the windows open.
POST /pointer/move{"x": 512, "y": 384}Moves the pointer.
POST /pointer/click{"x": 512, "y": 384, "button": "left", "count": 2}Presses and releases a mouse button: x and y are optional, button is left, middle, or right, and count is 1 to 10.
TerminalCode
unikraft api /v1/instances/<uuid>/plugins/novnc/screen -X PUT --metro fra \ '{"width": 1280, "height": 800}'

Learn more

Last modified on