Skip to content

Instantly share code, notes, and snippets.

@Lvdwardt
Created March 31, 2023 05:54
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Lvdwardt/707d9c3fb4581d38102399f91a21c9c6 to your computer and use it in GitHub Desktop.
Save Lvdwardt/707d9c3fb4581d38102399f91a21c9c6 to your computer and use it in GitHub Desktop.
Rustdesk + Nginx proxy manager
version: '3'
networks:
rustdesk-net:
external: false
services:
nginx-proxy-manager:
image: 'jc21/nginx-proxy-manager:latest'
restart: unless-stopped
ports:
# These ports are in format <host-port>:<container-port>
- '80:80' # Public HTTP Port
- '443:443' # Public HTTPS Port
- '8081:81' # Admin Web Port
# Add any other Stream port you want to expose
# - '21:21' # FTP
# Ports needed for Rustdesk:
- '21115:21115'
- '21116:21116'
- '21116:21116/udp'
- '21117:21117'
- '21118:21118'
- '21119:21119'
# Uncomment the next line if you uncomment anything in the section
# environment:
# Uncomment this if you want to change the location of
# the SQLite DB file within the container
# DB_SQLITE_FILE: "/data/database.sqlite"
# Uncomment this if IPv6 is not enabled on your host/
# DISABLE_IPV6: 'true'
volumes:
- ./data:/data
- ./letsencrypt:/etc/letsencrypt
networks:
- rustdesk-net
hbbs:
container_name: hbbs
image: rustdesk/rustdesk-server:latest
command: hbbs -r rustdesk.wijwetenhetwel.nl:21117
volumes:
- ./data:/root
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
networks:
- rustdesk-net
restart: unless-stopped
@Lvdwardt
Copy link
Author

Lvdwardt commented May 18, 2023

Steps:

  1. Create a new stack, name is important because we need it later

  2. Use the docker-compose above. Edit line 44 for the domain you want to use for this.

  3. Go to the proxy manager

  4. Go to the tab streams

  5. Create new streams for port 21115:21119 as shown in the image below.
    Make sure that port 21117 has both TCP and UDP selected.
    For port 21115, 21116 and 21118 use hbbs.[your_stack_name]_rustdesk-net.
    For port 21117 and 21119 use hbbr.[your_stack_name]_rustdesk-net.

  6. The last thing you need to do is point a domain name to the server. For example rustdesk.yourdomain.com. No need to specify the port, Nginx and RustDesk will handle the rest.

Nginx rustdesk configuration

encryption

If you want to encrypt your connection, you need to do a few more steps.

  1. open your console as root and navigate to the root of the server.
  2. navigate to data/compose/{number}/data. {number} depends on the number of other compose stacks you have in your docker setup. If this is the first docker-compose stack it should be 1. so cd data/compose/1/data
  3. Read the key in the id_ed25519.pub file. For example by running vim id_ed25519.pub or cat id_ed25519.pub.
  4. Copy the key, and then In the RustDesk client, you have to enter it in the key field in ID/Relay server.
  5. If both clients have added this key in their RustDesk settings the connection will now be encrypted!

Rustdesk ID/Relay server configuration

@itstueben
Copy link

Thx for the info how to use npm and rustdesk.
My Setup Fritzbox, ProxyManager and a machine with rustdesk
I have some questions.

  1. What Ports from fritzbox forwared to npm
  2. Need a proxy Host in npm?

@Lvdwardt
Copy link
Author

Thx for the info how to use npm and rustdesk. My Setup Fritzbox, ProxyManager and a machine with rustdesk I have some questions.

  1. What Ports from fritzbox forwared to npm
  2. Need a proxy Host in npm?

Hey!

  1. I haven't done any port forwarding. Only the streams in npm. But I'm hosting this on a Digital Ocean droplet, so I didn't have to forward any ports. I have a domain linked to the IP address and for me, it works without further configuration. I suppose you need to make sure the ports 21115:21119 are open on your Fritzbox. What I did is making a domain link to the IP of npm.

Also, make sure you've added the domain or IP to the ID server in the Rustdesk settings

  1. for Rustdesk you don't need to set up a proxy host, but you use proxy hosts for other things :)

@itstueben
Copy link

  1. I forwarded the ports for a special URL in fritzbox to npm. Looks all good
  2. ok

@GuySensei8
Copy link

GuySensei8 commented Mar 26, 2024

> ## Ste```
ps:
> 1. Create a new stack, name is important because we need it later
> 2. Use the docker-compose above
> 3. Go to the proxy manager
> 4. Go to the tab streams
> 5. Create new streams for port 21115:21119 as shown in the image below.
>    Make sure that port 21117 has both TCP and UDP selected.
>    For port 21115, 21116 and 21118 use `hbbs.[your_stack_name]_rustdesk-net`.
>    For port 21117 and 21119 use `hbbr.[your_stack_name]_rustdesk-net`.
> 6. The last thing you need to do is point a domain name to the server. For example rustdesk.yourdomain.com. No need to specify the port, Nginx and RustDesk will handle the rest.

Hello,

In the above instructions I am confused on # 6 where it says to have domain name point to my server. I am not sure if it was a given but how do I do that? Do I setup proxy host or do I do something else and point it to rustdesk? I am unsure on what you mean by that, it just seems vague compared to your other steps?

Please assist!

Thanks!

@GuySensei8
Copy link

GuySensei8 commented Mar 26, 2024

I know in the docker-compose file I set the domain I planned to use and then in cloudflare I set that as a CNAME DNS record. Is there more to it than that but it says it's successful when I add the host on the client but then it says "not ready. check network connection"????

@Lvdwardt
Copy link
Author

Hi,

I think you need to point the domain you want to use to the correct IP with an A record, not a CNAME record.

Regards!

@GuySensei8
Copy link

I thought of that too but when I did point it with an A record instead it still says not ready.

@GuySensei8
Copy link

Can it be proxied by cloudflare or does that have to be disabled?

@Lvdwardt
Copy link
Author

I do have it disabled

@Abejo
Copy link

Abejo commented Apr 19, 2024

Hi, I'm lost with this:
hbbs.[your_stack_name]_rustdesk-net
hbbr.[your_stack_name]_rustdesk-net
what would your_stack_name be? My domain?

@Lvdwardt
Copy link
Author

Hey, The name you gave the stack in step 1.

@unkelsunk
Copy link

Hi, I can't get the streams to work. I have rustdesk in a separate yml-file as above, since I have npm configured already. Ports bonded in original yml to npm, docker stack name is "docker" and network is npm_proxy. I use hbbr or hbbs .docker_npm_proxy for streams but it shows as offline. I'm not sure what is not working and would appreciate any help, thanks. Also thanks for putting up this guide!

@Lvdwardt
Copy link
Author

Lvdwardt commented Apr 29, 2024

Hi, I can't get the streams to work. I have rustdesk in a separate yml-file as above, since I have npm configured already. Ports bonded in original yml to npm, docker stack name is "docker" and network is npm_proxy. I use hbbr or hbbs .docker_npm_proxy for streams but it shows as offline. I'm not sure what is not working and would appreciate any help, thanks. Also thanks for putting up this guide!

hey, have you added this line in the npm stack as well?
networks: - rustdesk-net
It only works if they are all on the same "internal" network.

If that doesn't work I'd suggest moving your npm config over to the rustdesk stack.

@unkelsunk
Copy link

I ended up giving hbbr and hbbs static IP on the npm network and that worked forwarding streams to those IPs. Not sure why it doesn't work with the setup you have described in the guide though. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment