Using Ngrok to publish HTTP and SSH for your Rasperberry Pi

I have a Rasperberry Pi 2, and i put it in my home in the silent.  Sometimes I need to ssh to my Pi or view a website that I deployed to my Pi. I looked for a solution in the Internet. I found Ngrok. I really fitted my case. So in this post, I will share you the way to setup Ngrok on Rasperberry Pi in step by step.


Download Ngrok

You find the correct link to download at https://ngrok.com/download. You see “Linux ARM” and get the link.

After that, you do some commands to download and decompress:

Creating Configuration File for Ngrok

We need to publish two tunnels (ssh, http). So we have to create a Ngrok configuration file to declare those services.

I create a file named ngrok.yml with content as below

web_addr: means that I can access Ngrok Webpage on my Pi via http://RASPERBERRY_PI_IP_ADDRESS:4040

I also declare two protocols and address for two tunnels – SSH and HTTP

Installing Supervisor

We need run Ngrok as a daemon (in background). So I use Supervisor – a third-party process manager. You can install Supervisor with command.

After finishing the installation, we create a Supervisor configuration file at /etc/supervisor/config.d/ngrok.conf with content as below

Running the tunnels

In this step, we just need to run the program via Supervisor by command:

Verifying your works

Now, we open the browser and access http://PI_IP_ADDRESS:4040 to get the information of tunnels and try a test.