Skip to content

Self-hosted RustDesk remote desktop relay server with Docker Compose - secure, open-source TeamViewer alternative

Notifications You must be signed in to change notification settings

a-ariff/rustdesk-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RustDesk Server - Self-Hosted Remote Desktop Solution

πŸš€ Complete Docker Compose setup for RustDesk server - Your own secure, open-source TeamViewer alternative!

Docker RustDesk License

πŸ“‹ Overview

This repository provides a complete, production-ready Docker Compose setup for hosting your own RustDesk relay server. RustDesk is a secure, high-performance remote desktop application that serves as an excellent open-source alternative to TeamViewer.

✨ Features

  • πŸ”’ Self-hosted & Secure: Complete control over your remote desktop infrastructure
  • 🐳 Docker Compose: Easy deployment and management
  • 🌐 Cross-Platform: Works with Windows, macOS, Linux, iOS, and Android clients
  • ⚑ High Performance: Low latency remote desktop experience
  • πŸ“± Mobile Support: Control your devices from anywhere
  • πŸ” Encrypted Connections: End-to-end encryption for all sessions
  • πŸš€ Easy Setup: Get running in minutes with our configuration

πŸ›  Quick Setup

Prerequisites

  • Docker and Docker Compose installed
  • A server with public IP (VPS/dedicated server)
  • Ports 21115-21119 available and accessible

1. Clone Repository

git clone https://github.com/a-ariff/rustdesk-server.git
cd rustdesk-server

2. Configure Environment

cp .env.example .env
# Edit .env file with your settings

3. Deploy Server

docker-compose up -d

4. Get Your Key

# Get the public key for client configuration
docker-compose logs hbbs | grep "Key:"

πŸ”§ Configuration

Environment Variables (.env)

# Server Configuration
SERVER_IP=your.server.ip.address
RELAY_DOMAIN=your-domain.com

# Container Settings
HBBS_PORT=21115
HBBR_PORT=21116
HBBR_PORT_WS=21117

# Security
ENCRYPTED_ONLY=Y
KEY_FILE=/root/key.pem

# Logging
RUST_LOG=info

Docker Compose Services

HBBS (RustDesk Relay Server)

  • Port 21115: Main relay service
  • Port 21116: NAT traversal
  • Handles client connections and authentication

HBBR (RustDesk Bridge Server)

  • Port 21116: Bridge service
  • Port 21117: WebSocket support
  • Manages peer-to-peer connections

🌐 Required Ports & Firewall

Port Configuration

Port Protocol Service Description
21115 TCP HBBS Main relay server
21116 TCP HBBR Bridge server
21116 UDP HBBS NAT traversal
21117 TCP HBBR WebSocket
21118 TCP HBBS Web console (optional)
21119 TCP HBBR Alternative port

Firewall Rules

UFW (Ubuntu/Debian)

sudo ufw allow 21115:21119/tcp
sudo ufw allow 21116/udp
sudo ufw reload

Firewalld (RHEL/CentOS)

sudo firewall-cmd --permanent --add-port=21115-21119/tcp
sudo firewall-cmd --permanent --add-port=21116/udp
sudo firewall-cmd --reload

iptables

sudo iptables -A INPUT -p tcp --dport 21115:21119 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 21116 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4

πŸ“± Client Configuration

Desktop Clients (Windows/macOS/Linux)

  1. Download RustDesk from official website
  2. Open Settings β†’ Network
  3. Configure server settings:
    ID Server: your.server.ip.address:21115
    Relay Server: your.server.ip.address:21116
    Key: [paste your server key here]
    
  4. Apply settings and restart RustDesk

Mobile Clients (iOS/Android)

  1. Download RustDesk from App Store/Google Play
  2. Go to Settings β†’ Advanced
  3. Set server configuration:
    • Server: your.server.ip.address
    • Key: [your server key]
  4. Save and restart the app

Custom Clients (Web)

Access the web client at: https://your.server.ip.address:21118

πŸ” Security Best Practices

SSL/TLS Configuration

# Add to docker-compose.yml for HTTPS
services:
  nginx:
    image: nginx:alpine
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
      - ./ssl:/etc/ssl/certs

Key Management

# Generate new encryption key
openssl genpkey -algorithm RSA -out key.pem -pkcs8

# Set proper permissions
chmod 600 key.pem
chown root:root key.pem

Access Control

# Restrict access by IP (optional)
docker-compose exec hbbs rustdesk-server --allow-ip "192.168.1.0/24,10.0.0.0/8"

πŸ“Š Monitoring & Maintenance

Health Checks

# Check service status
docker-compose ps

# View logs
docker-compose logs -f hbbs
docker-compose logs -f hbbr

# Monitor connections
docker-compose exec hbbs netstat -tuln

Backup Configuration

#!/bin/bash
# backup.sh
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p backups
cp .env backups/.env_$DATE
cp docker-compose.yml backups/docker-compose_$DATE.yml
echo "Backup completed: $DATE"

Updates

# Update containers
docker-compose pull
docker-compose down
docker-compose up -d

# Clean old images
docker system prune -f

πŸš€ Advanced Configuration

Custom Domain Setup

# Add to your DNS:
# A record: rustdesk.yourdomain.com β†’ your.server.ip.address

# Update .env:
RELAY_DOMAIN=rustdesk.yourdomain.com

Load Balancing

services:
  hbbs-1:
    image: rustdesk/rustdesk-server:latest
    command: hbbs -r hbbr-1:21117
    
  hbbs-2:
    image: rustdesk/rustdesk-server:latest
    command: hbbs -r hbbr-2:21117
    
  nginx-lb:
    image: nginx:alpine
    # Load balancer configuration

πŸ› Troubleshooting

Common Issues

Connection Failed

# Check if ports are open
telnet your.server.ip.address 21115

# Verify firewall rules
sudo ufw status

# Check container logs
docker-compose logs hbbs

Key Errors

# Regenerate server key
docker-compose down
docker-compose run --rm hbbs rustdesk-server --gen-key
docker-compose up -d

Performance Issues

# Monitor resource usage
docker stats

# Check network latency
ping -c 10 your.server.ip.address

Support

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

⭐ Support This Project

If this repository helped you set up your RustDesk server, please consider:

  • ⭐ Starring this repository
  • πŸ› Reporting issues
  • πŸ’‘ Suggesting improvements
  • 🀝 Contributing code

Made with ❀️ by Ariff Mohamed

Self-hosted remote desktop solution for ultimate privacy and control

About

Self-hosted RustDesk remote desktop relay server with Docker Compose - secure, open-source TeamViewer alternative

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published