Raspberry Pi — secured webcam streaming with motion, nginx and ngrok

Daniel Herman
4 min readAug 5, 2021

This guide will show you how to stream with motion, create an authentication gate with nginx and tunnel the stream with ngrok to the internet.

Motivation

You are looking for some low-cost solution on how to monitor your home garden or home gate? Then this guide is for you! You will need only an internet connection if you want to access your home webcam anywhere from the internet and Raspberry Pi (even older models like RPi 2).

Setting up your Raspberry Pi

If you already set up your Raspberry Pi (RPi), you can skip this section. Download “Raspberry Pi OS Lite” from here. Flash it on your SD card with your favourite disk image writer. Make sure your RPi is connected to the internet. The default user is pi, and the password is raspberry. Boot RPi OS and run (prepare yourself that it will take a while)

sudo apt update 
sudo apt upgrade

Change the default user password to something else with

passwd

Optionally change the keyboard layout to US with

sudo nano /etc/default/keyboard

The file should look like the following

# KEYBOARD CONFIGURATION FILE# Consult…

--

--

Daniel Herman

Data Scientist | graduated Physics student at Charles university in Prague | theoretical biophysics and chemical physics