π Complete Docker Compose setup for RustDesk server - Your own secure, open-source TeamViewer alternative!
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.
- π 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
- Docker and Docker Compose installed
- A server with public IP (VPS/dedicated server)
- Ports 21115-21119 available and accessible
git clone https://github.com/a-ariff/rustdesk-server.git
cd rustdesk-server
cp .env.example .env
# Edit .env file with your settings
docker-compose up -d
# Get the public key for client configuration
docker-compose logs hbbs | grep "Key:"
# 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
- Port 21115: Main relay service
- Port 21116: NAT traversal
- Handles client connections and authentication
- Port 21116: Bridge service
- Port 21117: WebSocket support
- Manages peer-to-peer connections
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 |
sudo ufw allow 21115:21119/tcp
sudo ufw allow 21116/udp
sudo ufw reload
sudo firewall-cmd --permanent --add-port=21115-21119/tcp
sudo firewall-cmd --permanent --add-port=21116/udp
sudo firewall-cmd --reload
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
- Download RustDesk from official website
- Open Settings β Network
- Configure server settings:
ID Server: your.server.ip.address:21115 Relay Server: your.server.ip.address:21116 Key: [paste your server key here]
- Apply settings and restart RustDesk
- Download RustDesk from App Store/Google Play
- Go to Settings β Advanced
- Set server configuration:
- Server:
your.server.ip.address
- Key:
[your server key]
- Server:
- Save and restart the app
Access the web client at: https://your.server.ip.address:21118
# 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
# Generate new encryption key
openssl genpkey -algorithm RSA -out key.pem -pkcs8
# Set proper permissions
chmod 600 key.pem
chown root:root key.pem
# Restrict access by IP (optional)
docker-compose exec hbbs rustdesk-server --allow-ip "192.168.1.0/24,10.0.0.0/8"
# 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
#!/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"
# Update containers
docker-compose pull
docker-compose down
docker-compose up -d
# Clean old images
docker system prune -f
# Add to your DNS:
# A record: rustdesk.yourdomain.com β your.server.ip.address
# Update .env:
RELAY_DOMAIN=rustdesk.yourdomain.com
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
# Check if ports are open
telnet your.server.ip.address 21115
# Verify firewall rules
sudo ufw status
# Check container logs
docker-compose logs hbbs
# Regenerate server key
docker-compose down
docker-compose run --rm hbbs rustdesk-server --gen-key
docker-compose up -d
# Monitor resource usage
docker stats
# Check network latency
ping -c 10 your.server.ip.address
- π Documentation: RustDesk Official Docs
- π¬ Community: RustDesk Discord
- π Issues: Report Issues
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
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