- Implementation of a remote access infrastructure by deploying the hbbs and hbbr services.
- Comprehensive configuration of TCP and UDP ports to ensure connectivity and NAT bypass.
- Ensuring privacy and data control through self-hosting of signaling and relay.

How to set up your own Rustdesk server with Docker? If you're tired of relying on proprietary tools and want complete control over your remote desktop sessions, setting up your own infrastructure with Rustdesk is the perfect solution. It's basically an open-source alternative to giants like TeamViewer or AnyDesk, but with the added value that you own the server, which means that your data does not pass through other hands and you forget about those pesky license limitations.
For those who don't want to complicate their lives with manual installations, Docker is the fastest route and efficient. Not only does it allow you to deploy the server in a flash, but it also makes updates a breeze and deployment repeatable on any machine, whether it's a cloud VPS, a home server, or even a Raspberry Pi if you feel like experimenting.
How does a self-hosted server actually work?

To understand what we're building, it's important to know that RustDesk isn't a single program, but rather relies on two fundamental executables. On one hand, we have hbbs (ID Server), which is responsible for signaling and ensuring that the teams find each other. On the other hand there is hbbr (Relay Server)which comes into play when the direct connection fails and traffic must bounce through the server.
The process is simple: the client constantly pings the ID server to let it know it's online. When you try to connect computer A to computer B, the hbbs server attempts to establish a connection. hole punching to establish a direct tunnel. If this doesn't work due to an aggressive firewall, then hbbr takes over to retransmit the data, ensuring that the connection is established no matter what.
Technical requirements and environment preparation

You don't need to spend a fortune on hardware; the requirements are extremely low. With a Linux server (we're talking about Ubuntu 22.04 or 24.04 LTSWith 1 vCPU and 2 GB of RAM, you'll have more than enough to handle dozens of simultaneous connections. However, it's essential to have a Fixed public IP address so that your customers don't lose track of the server.
Before launching containers, you need to prepare by installing Docker and Docker Compose. If you use more specific environments such as UnraidYou can use optimized images (like Ich777's) that simplify the process, integrating everything into a more visual and manageable interface.
Port and Firewall Configuration

This is where most people go wrong. For everything to work smoothly, you need to open the specific ports in your firewall (whether it's UFW on Linux or your cloud provider's control panel). essential ports They are TCP 21115, TCP 21116, and UDP 21116. The latter is critical as it handles the ID register and the system heartbeat.
Additionally, you need TCP port 21117 for the Relay service. If you plan to use the RustDesk web clientYou will need to enable TCP ports 21118 and 21119 (WebSockets). For Pro users who do not use an SSL proxy, TCP port 21114 is required for the API to function correctly, although ideally everything should be routed through a reverse proxy like Nginx to use HTTPS over port 443.
Step-by-step deployment with Docker Compose

The cleanest way to do this is by creating a dedicated folder, for example in /opt/rustdesk-server/and drafting a file compose.ymlA vital detail is to use network_mode: «host»because RustDesk needs to know the host's real IP address to prevent traffic redirection from becoming chaotic.
Once the file is configured, you start the services with a simple command. After startup, it is essential. obtain the public key of the server. This key is located in the persistent data directory and is the "handshake" that ensures only authorized clients connect to your infrastructure. If you don't set up the persistent data volumesYou will lose this configuration every time you update the container.
Client settings and advanced security
With the server up and running, go to your RustDesk client's network settings. You need to enter your server's IP address in both the Server ID as in the Relay Serverand paste the public key we retrieved earlier. If you use a service like DuckDNSYou can use the domain instead of the IP address to avoid relying on changes to the server address.
To make your network a bunker, don't just stop at installation. You can implement one-time passwords for one-off support or permanent keys for your own teams. If you're looking for the highest level, activate the Two-factor authentication (2FA) via applications or Telegram. For corporate environments, the most sensible thing to do is to close the server firewall so that it only accepts connections from Corporate IPs or through a VPNthus creating a completely closed and private network.
Differences with the Pro version
Although the OSS version is fantastic, RustDesk offers a Pro variant for those who need centralized user management and groups. This version allows integration of the server with Active Directory or LDAP and offers much more detailed audit logs, which is an essential requirement in many companies due to security regulations.
Having your own RustDesk server using Docker allows you to eliminate intermediaries, reduce latency and ensure that remote access to your machines is private and efficient. By combining proper port configuration, the use of persistent volumes, and security layers such as 2FA or VPNs, you transform a simple tool into a powerful one. professional support infrastructure under your complete control.
Passionate about technology since he was little. I love being up to date in the sector and, above all, communicating it. That is why I have been dedicated to communication on technology and video game websites for many years. You can find me writing about Android, Windows, MacOS, iOS, Nintendo or any other related topic that comes to mind.