How to expose Repetier Server to the internet using ngrok in 5 minutes.

If you're like me, you're using some tool like Repetier Server or Octoprint to connect your 3D Printers to. That's all nice and fun, until you realise that you're actually sometimes leaving your place. Wouldn't it be nice to have your Repetier Server reachable from the internet? Well, not that hard really. 

I'm using Repetier Server, running on a Raspberry Pi. I've used the preconfigured image that you can download from the Repetier Site. It's a Debian based distribution, and that's slightly important. 

While there's probably good reasons to go for a Raspberry Pi 4 or 5, my setup is a Raspberry Pi 3 (Affiliate Link). It's reliably running Repetier Server with two printers connected, as well as cnc.js simulatenously. 

Please make sure you've got the IP address of your Raspberry Pi running Repetier ready, and that you know how to connect via SSH, and that it works. If not, there's a great guide that has you covered.

The first tool is up and running (Repetier), so let's quickly move over to ngrok. Ngrok is one of those services that are just awesome, plain and simple. It opens a tunnel from the internet to wherever you need it to be. In it's simplest version you can simply install it and run from a shell 

ngrok http 80

And it will make your local machine accessible, on port 80, serving http traffic. This is extremely useful in software development, but also has other applications, like the one we're talking about today. 

Yes, you're making a personal host accessible on the internet. Make sure that's what you want and be aware of the risk. Make sure you're using authentication in Repetier to ensure you need to be logged in to, well, do anything. 

First, head over to the install page and find the debian install option, it's named "Install ngrok via Apt". After pasting that command into your shell, you should have it available. 

Once you run ngrok (ngrok http 80 is good to test), it'll assign you a fancy domain name and you can access your host from anywhere. Now, there's a few problems. 

Firstly, the domain name changes everytime, so it's a little cumbersome to always memorize it. Second problem is that we're calling ngrok manually, having that one automatically start when the system boots would again be nicer. So let's do that. 

The very first thing you'll need is a ngrok authorization token, or Authtoken, in ngrok terms. After creating a free account, you can get that here. After installing it according to the instructions, head over to Cloud Edge -> Domains. The awesome folks at ngrok provide even free plan users with a free domain that remains static and can be used for all sorts of sheningans. 

Write it down somewhere. 

in the next step, we want to try if our setup worked up until here. For that, we're simply restarting ngrok with the domain argument – that way, it'll establish a tunnel that will be reachable using our fancy static domain. 

ngrok http 80 --domain whatever-your-domain-is-weird-bear-cat.ngrok-free.app

If all is correctly setup – that is, your Authtoken, ngrok and the domain – you can now head to whatever your static domain is and you should see the Repetier Server home page. If that doesn't work, ensure that Repetier is running and double check the Authtoken, the domain name and your general sanity. Maybe also go for a walk. 

The last remaining step is to hook ngrok up to Debians service management. This consists of putting a service file into a known directory, making the service daemon reload the known services, and starting the service. 

The service file looks like this 

To download it to the right directory, you can run this: 

sudo curl https://gist.githubusercontent.com/moritzh/23fe799a731f460e305f1f5b45c79437/raw/c47bd49ca708b22b615b24095bac92da2f02086c/ngrok.service -o > sudo /etc/systemd/system/ngrok.service

however, there's 2 sudos in there, so I'd probably just manually create the file and paste the contents there – really depends on how reckless you are. But it's my blog, my rules, so we're doing reckless things. 

Last step is to replace the placeholders with both your username (you can run `whoami` to see what that is) and your domain name. Fire up nano and do the thing: 

sudo nano /etc/systemd/system/ngrok.service

After that there's only one thing left to do: Start the service.

sudo systemctl daemon-reload; sudo systemctl start ngrok

You can check if everything worked by both going to your fixed domain – that should work, but you can also always check via 

sudo systemctl status ngrok

That's it! Now you can always check you Repetier Server from everywhere. 

This article was updated on October 16, 2023

Hi, I'm Moritz. Professionally, I'm an Engineering Leader who's helping teams to deliver awesome things in healthy ways. After hours, I love hardware as much as I love software. CNC Milling, 3D Printing, Modelling, Soldering, you name it. I'm writing about that here. 

Comments