Skip to content

Access TurboVNC via a unix socket instead of a port #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
run: |
# -help flag is not available for TurboVNC, but it emits the -help
# equivalent information anyhow if passed -help, but also errors. Due
# to this, we fallback to use the errorcode of vncsrever -list.
# to this, we fallback to use the errorcode of vncserver -list.
docker run test bash -c "vncserver -help || vncserver -list > /dev/null"
- name: Test vncserver
Expand Down
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ When this extension is launched it will run a Linux desktop on the Jupyter singl

## VNC Server

This extension requires a [VNC Server](https://en.wikipedia.org/wiki/Virtual_Network_Computing)
to be installed on the system (likely, in the container image). The
most tested VNC server is [TigerVNC](https://tigervnc.org/), while
[TurboVNC](https://www.turbovnc.org/) also works. Any VNC server available
in `$PATH` as `vncserver` will be used, but no real testing outside of
these servers has been performed.

For an example, see the [`Dockerfile`](./Dockerfile) in this repository which installs TigerVNC and XFCE4.
This extension requires installing a [VNC server] on the system (likely in a
container image). Compatibility with the latest version of [TigerVNC] and
[TurboVNC] is maintained and verified with tests, but other VNC servers
available in `$PATH` as `vncserver` could also work. The `vncserver` binary
needs to accept the [flags seen passed here], such as `-rfbunixpath` and a few
others.

For an example, see the [`Dockerfile`](./Dockerfile) in this repository which
installs either TigerVNC or TurboVNC together with XFCE4.

[vnc server]: https://en.wikipedia.org/wiki/Virtual_Network_Computing
[tigervnc]: https://tigervnc.org/
[turbovnc]: https://www.turbovnc.org/
[flags seen passed here]: https://github.com/jupyterhub/jupyter-remote-desktop-proxy/blob/main/jupyter_remote_desktop_proxy/setup_websockify.py
[xfce4]: https://www.xfce.org/

## Installation

Expand All @@ -35,7 +42,7 @@ For an example, see the [`Dockerfile`](./Dockerfile) in this repository which in

2. Install the packages needed to provide a VNC server and the actual Linux Desktop environment.
You need to pick a desktop environment (there are many!) - here are the packages
to use TigerVNC and the light-weight [XFCE4](https://www.xfce.org/) desktop environment on Ubuntu 22.04:
to use TigerVNC and the light-weight [XFCE4] desktop environment on Ubuntu 24.04:

```
dbus-x11
Expand All @@ -46,7 +53,6 @@ For an example, see the [`Dockerfile`](./Dockerfile) in this repository which in
xorg
xubuntu-icon-theme
tigervnc-standalone-server
tigervnc-xorg-extension
```

The recommended way to install these is from your Linux system package manager
Expand Down
24 changes: 3 additions & 21 deletions jupyter_remote_desktop_proxy/setup_websockify.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,8 @@ def setup_websockify():
"vncserver executable not found, please install a VNC server"
)

# TurboVNC and TigerVNC share the same origin and both use a Perl script
# as the executable vncserver. We can determine if vncserver is TigerVNC
# by searching tigervnc string in the Perl script.
#
# The content of the vncserver executable can differ depending on how
# TigerVNC and TurboVNC has been distributed. Below are files known to be
# read in some situations:
#
# - https://github.com/TigerVNC/tigervnc/blob/v1.13.1/unix/vncserver/vncserver.in
# - https://github.com/TurboVNC/turbovnc/blob/3.1.1/unix/vncserver.in
#
with open(vncserver) as vncserver_file:
is_tigervnc = "tigervnc" in vncserver_file.read().casefold()

if is_tigervnc:
unix_socket = True
vnc_args = [vncserver, '-rfbunixpath', "{unix_socket}"]
else:
unix_socket = False
vnc_args = [vncserver, '-localhost', '-rfbport', '{port}']
# {unix_socket} is expanded by jupyter-server-proxy
vnc_args = [vncserver, '-rfbunixpath', '{unix_socket}']

xstartup = os.getenv("JUPYTER_REMOTE_DESKTOP_PROXY_XSTARTUP")
if not xstartup and not os.path.exists(os.path.expanduser('~/.vnc/xstartup')):
Expand Down Expand Up @@ -59,6 +41,6 @@ def setup_websockify():
# /desktop/ is the user facing URL, while /desktop-websockify/ now *only* serves
# websockets.
"launcher_entry": {"title": "Desktop", "path_info": "desktop"},
"unix_socket": unix_socket,
"unix_socket": True,
"raw_socket_proxy": True,
}