rclient RustDesk web client displaying a remote desktop session in the browser

Self-host a RustDesk web client in 10 minutes

•

The last time I needed to help someone on a locked-down work computer, installing a remote desktop client was not an option. No admin rights, no account, no software. What was available was a browser. RustDesk’s native apps are excellent, but they have to be installed on the machine you connect from, which is useless in that situation. rclient is my answer: a web client that speaks RustDesk’s protocol through a relay I control. In this post I will get a working deployment up with two Docker containers.

I wrote the client because the official RustDesk web client did not work well with self-hosted relays. If you already run a RustDesk server, the setup below is mostly copying values from its logs. If you do not, the repo’s deployment guide starts a relay from scratch. There is also a live demo if you want to see it before installing anything.

What you are actually running

The stack has four moving parts, and only two of them are in this repository:

  • The host is the machine you want to control. It runs the normal RustDesk app, pointed at your relay.
  • The relay is hbbs (rendezvous) plus hbbr (stream). You run it yourself; rclient deliberately ships no relay. The official RustDesk self-hosting guide covers that part if you are new to it.
  • The gateway is a Node.js container. It holds the RustDesk session encryption, speaks the binary protocol, and bridges it to a browser WebSocket. It listens on port 4000 internally and must never be published.
  • The web container is nginx serving the React app. It proxies /ws and /config to the gateway and is the only part exposed publicly.

In one line: Browser - HTTPS/WSS -> web (nginx) -> gateway (Node) -> your relay -> host. The browser never sees a session key; the gateway does the crypto. That split is why putting the gateway on the public internet is a bad idea – it holds keys.

Deploy in a few commands

Clone the repo and fill in an env file from the example:

git clone https://github.com/linkzy/rustdesk-custom-web-client
cd rustdesk-custom-web-client
cp .env.example .env        # edit: HBBS_HOST, HBBR_HOST, SERVER_KEY
docker compose -f docker-compose.prod.yml up -d

The production compose file uses published images from GHCR, so there is no build step. Here is a trimmed version of what it does:

services:
  gateway:
    image: ghcr.io/linkzy/rclient-gateway:latest
    restart: unless-stopped
    environment:
      - HBBS_HOST=${HBBS_HOST}
      - HBBS_WS_PORT=${HBBS_WS_PORT:-21118}
      - HBBR_HOST=${HBBR_HOST}
      - HBBR_WS_PORT=${HBBR_WS_PORT:-21119}
      - SERVER_KEY=${SERVER_KEY}
      - GATEWAY_PORT=4000
    expose:
      - "4000"          # never "ports": gateway holds session keys
    networks: [rclient]

  web:
    image: ghcr.io/linkzy/rclient-web:latest
    restart: unless-stopped
    ports:
      - "${WEB_PORT:-80}:80"
    depends_on: [gateway]
    networks: [rclient]

networks:
  rclient:
    driver: bridge

The values you need in .env are small in number but easy to get wrong:

HBBS_HOST=your-rustdesk-server.com     # rendezvous host
HBBS_WS_PORT=21118                     # gateway talks WS to hbbs
HBBR_HOST=your-rustdesk-server.com     # relay host, usually the same box
HBBR_WS_PORT=21119                     # gateway talks WS to hbbr
SERVER_KEY=your-server-public-key     # base64 key from hbbs on first run
WEB_PORT=80                            # where the web container listens

The public key comes from the hbbs logs on first run. Both ends – the host machine and the gateway – must point at the same relay and use the same key. A host still registered on RustDesk’s public network will not be found by your private relay; that is a separate network, not a routing problem.

Put HTTPS in front of it

This step is not optional. Browsers only expose WebCodecs in a secure context, so the video decoder will not work over plain HTTP – except on localhost. Serve the web container through a Cloudflare Tunnel, Caddy, nginx, or Traefik with a real certificate. In my deployment the tunnel forwards to the web container and no port is opened on the firewall at all.

Whatever proxy you choose, it must forward WebSocket upgrades. A reverse proxy that drops the upgrade is the most common failure: the page loads fine, then /ws closes immediately. If you see that, check the proxy config before you touch the relay. Keep port 4000 unexposed; nginx handles the browser-facing socket.

Connect a host and test it

On the machine to be controlled, open RustDesk, go to Network next to your ID, and set ID Server to your relay hostname and Key to the public key. Apply and wait for the status to go green. Then open your web client over HTTPS, enter the machine’s RustDesk ID and password, and connect. Advanced options let you override the relay per connection, which is handy while testing without changing the gateway’s environment.

The password is only kept in memory unless you tick “Remember password”, in which case it goes to localStorage after a successful connection. Leave that box off on shared computers. The gateway hashes the password before sending it to the host and never logs it.

Troubleshooting the two failures I hit most

“Machine is offline.” RustDesk is not running on the host, or the host and gateway disagree about the relay. Check both ends: same hostname, same key.

Connects, then sits at “waiting for image”. Rendezvous worked but the stream did not. The gateway forces relay mode rather than trying direct peer-to-peer, so the relay path is always in play. Check that ports 21117 and 21119 are reachable from both the gateway and the host. The browser console also logs the codec the decoder tried to initialise; no video at all usually means WebCodecs is unavailable or the page is not on HTTPS. If video works but there is no audio, that browser lacks AudioDecoder – the session carries on without it.

These are known, documented limits rather than bugs to chase: no file transfer, no clipboard sync, no forwarded Ctrl+C / Ctrl+V, one display, and no automatic reconnect. Mouse and keyboard input, H264/VP9/VP8/AV1 video, and Opus audio work in current browsers. The rclient repository has the full deployment guide and a demo relay recipe, and the companion post on WebCodecs in practice explains what happens once the frames reach the browser.

Leave a Reply

Your email address will not be published. Required fields are marked *


Categories


Tag Cloud

.net Agents algorithms angular api Array arrays basic-concepts big o blazor c# classes code components containers control-structures csharp data structures Deep Learning dictionaries docker dom dotnet framework functions git guide javascript json leetcode linq lists LLM methods MVC Natural Language Processing npm object oriented programming oop operators Python sorted tutorial typescript web framework