I'm interested in how network stuff (protocols, etc.) work and always found ngrok a really neat tool and wanted to learn how it works internally. It was obvious to me that I would not be able to replicate such a great tool easily or even replicate it at all. That's why I settled for a way smaller version. Recently being intereseted in learning and using more rust for system level programming this was a great fit to learn it more.

While developing I wanted to go to the deepest layer and still achieve my goal was using this ssh library which was wrapped in rust. But sadly I ran into multiple problems with it throwing errors which I didn't find out how to resolve (See my WIP). So I went with using the ssh program which is locally installed on the machine where I run. This has the nice added benifit that I get the configuration for the servers made in ~/.ssh/config for free.

Installation

Server

First of all you have to create the server executable, upload that to the server and allow it to change the config of nginx.

  1. To create the binary run the following in the server folder:

ZUNDER_DOMAIN=your-domain.dev cargo rustc --release --target x86_64-unknown-linux-musl -- -C linker=rust-lld

This compiles the server into a binary.

  1. Copy the binary to the server.

scp target/x86_64-unknown-linux-musl/release/zunder-server server:/usr/bin

  1. On the server make the binary sticky to root

chown root zunder-server && chmod u+s zunder-server

  1. Create a wildcard-certificate for your domain with let's encrypt.

Client

  1. cargo install zunder
  2. Run zunder create in a project folder which you want to forward
  3. Edit your .zunder.toml to change the port you want to forward, where the server can be reached and which subdomain should be used.
  4. Run zunder
  5. It should now be connected to the server an create the subdomain for nginx automatically and proxy all your requests.

Usage

Don't use this in production as it is only a little more than a proof of concept.

Here is a config I use for a project using ember (hence the port 4200):

localport = 4200
remoteport = 57407
subdomain = "pp"
ssh = "os"