SelfHost RustDesk using Docker and Plesk

Setting up your own RustDesk (Community Version) using Docker seems to be simple. But what i did not found was a HowTo do this using a VServer that is running Plesk. Some things should be easier / using more automation than doing everything manually.

So here is my HowTo do this.

Add a new Subdomain

Login to your Plesk and add a new Subodmain like rustdesk.my.domain or rd.my.domain.

Also we will directly activy Let’s Encrypt so that our RustDesk will be protected using https.

It is free and Plesk will automatically renew it.

Activate Docker

RustDesk describes how to set up Docker / links to it.

Those manually steps can be easily done by using the Docker Extension which is free. (There are Options for Remote Node Management that need to be paid for but for simple use cases it is enough).

So let’s go to Extensions and search for Docker. The offical Plesk Docker Extension should show up.

Get RustDesk Docker Image

In the new Docker Area we can now navigate to Images and Search for “rustdesk”

We require the rustdesk/rustdesk-server image. If you click on it

you are now able to download the latest version.

Use Docker-Compose directly

Plesk currently cannot use Docker Compose.

It will be available in the future (see https://talk.plesk.com/threads/how-to-use-docker-compose.373539/) but is not yet available.

So we will need to work on the Console.

mkdir /opt/rustdesk

cd /opt/rustdesk

vi docker-compose.yml

Content of docker-compose:

networks:
  rustdesk-net:
    external: false
services:
  hbbs:
    container_name: hbbs
    image: rustdesk/rustdesk-server:latest
    ports:
      - 21115:21115
      - 21116:21116
      - 21116:21116/udp
      - 21118:21118
    environment:
      - ALWAYS_USE_RELAY=Y
    command: hbbs -r 127.0.0.1:21117 -k _
    volumes:
      - ./hbbs:/root
    networks:
      - rustdesk-net
    depends_on:
      - hbbr
    restart: unless-stopped

  hbbr:
    container_name: hbbr
    image: rustdesk/rustdesk-server:latest
    ports:
       - 21117:21117
       - 21119:21119
    command: hbbr -k _
    volumes:
      - ./hbbr:/root
    networks:
      - rustdesk-net
    restart: unless-stopped

This will setup required services and store the data besides our docker-compose.yml.

Also using “-k _” it will not publicly be accessible without the public-key for the Relay-Server. Also we do not want a direkt Client2Client connection, everything should go over out https secured Relay (ALWAYS_USE_RELAY=Y).

Other HowTo’s expose the ports directly on your server (opening it in the firewall like in ufw for Ubuntu). Here we setup a private network so that the services may communicate together but it will not be externally availble.

It should now start using

docker compose up -d

We are also now able to see it running and access logs… in Plesk.

Make it available to the “World”

The Docker Plesk Extensions added a new option to add Proxy-Rules to our Subdomain so that it will be running behing our https Proxy.

Click on it on your Subdomain and we will be able to add a new Rule:

The only required Port is 21117 from the hbbr Container.

Configure Client

Now after downloading the Client from the offical RustDesk Page we can start it.

It will also inform you to use your own Server. to do this open the Menu and go to the Network Settings.

There we will configure our ID/Relay-Server.

It is enough to set the ID-Server to our Subdomain.

Also we will need the public Key. (which you should only give to people who should have access to your Server).

To get your public-Key you can access it from the Console using:

cat /opt/rustdesk/hbbs/id_ed25519.pub

The output is your Key. After pressing OK you should be good to go.

Zabbix detect Public IP Change

If you do not have a fixed IP you may already also be using something like DynDns to access your own Home-Network.

If you are also using Zabbix for Monitoring you may want to include an additional Information Layer to be notfied, when your public IP changes.

Reason? I myself also have had the problem that the DynDns Update failed and i had no information what my new “public IP” was. If Zabbix sends an EMail (it has had new Internet-Access) than you may be able to “recover” and dial in again (VPN…) using the IP and not your Dynamic DNS Name.

Getting public IP

How can you get your public IP?

There are a lot of Services to get it. Just use google.

Eg. ipfy “https://api.ipify.org/?format=plain” will provide it.

You may also use a simple custom solution on your own VServer or Webhosting-Package/Domain like setting up a PHP-Script to send back your IP.

Example (myip.php):

 <?php
echo $_SERVER['REMOTE_ADDR'];
?>

Create Zabbix Host

If you have already created a Host (see Zabbix Internet Connectivity Check) you can use it. Or else create it.

Create Item to get public IP

The Web Scenarios do not work for this Use-Case.

But there is a HTTPAgent in Zabbix.

Go to items and Create a new one.

Name: GetPublicIP

Type: “HTTP agent”

Key: public_ip

Type of Information: Character

URL:

Custom: https://my.domain/myip.php

Or a public available Service URL

Update Interval: 5m

Press Add.

Create Trigger

Now go to Triggers and Create a new one.

Name: PublicIPChange {ITEM.VALUE}

Severity: Information

Description: Public IP has Changed {ITEM.VALUE}

Expression:

(last(/Network connectivity checks/public_ip,#1)<>last(/Network connectivity checks/public_ip,#2))>0

Press Add and that’s it. Now if you want to test it just disconnect and reconnect to the internet and Zabbix will send an Notification that your IP changed. (Also 5min later it will also be automatically resolved).

Zabbix Internet Connectivity Check

Simple HowTo create a Internet Connectivity Check for Zabbix.

Create new Host

Create a new Host named “Network connectivity checks”

You do not need to add any Interfaces.

Add Web Scenario to Host

On our newly created Host go to “Web Scenarios”.

Press “Create web Scenario”

You can use your own Server or check Google.

For our Example we are going to use google.

Name of new Scenario: “Check Google Connectivity”

Update-Interval: 5m

Agent: Zabbix

Go to the Steps Tab and press “Add”

Name: “Google”

URL: “https://www.google.com”

Required Status Code: 200

Press the Add-Button to add the Step and than Add to add the Scenario.

Create a Trigger

Now we go to the Triggers Tab and pres “Create trigger”.

Name: “Google Accessibility {ITEM.VALUE}”

Severity: High

Expression:

length(last(/Network connectivity checks/web.test.error[Check Google Connectivity]))>0 and last(/Network connectivity checks/web.test.fail[Check Google Connectivity])>0

Press Add and we are Finished.

Now if you want to test it, disconnect from the Internet and wait a moment.

A new Problem should be created. If you have In-House Mailing (no internet contection required) you should get a new Problem-Notification from Zabbix.