Operations 13 min read

Turn a Raspberry Pi Zero W into a Mini Web Server with SSH and Ngrok

This step‑by‑step guide shows how to choose a Raspberry Pi Zero W, flash Raspbian Stretch Lite onto a micro‑SD card, enable headless SSH, configure Wi‑Fi, install and run Nginx, and expose the server to the internet using Ngrok, all while keeping the device compact and efficient.

Top Architect
Top Architect
Top Architect
Turn a Raspberry Pi Zero W into a Mini Web Server with SSH and Ngrok

What is Raspberry Pi?

Raspberry Pi (RPi) is a credit‑card‑sized micro‑computer that runs Linux; with Windows 10 IoT it can also run Windows.

Zero W Overview

Zero W is a miniature version of the Pi, about one‑third the size of a 3B+, featuring a 1 GHz BCM2835 CPU, 512 MB RAM, Wi‑Fi/BT, micro‑USB power, OTG, mini‑HDMI, CSI camera connector, GPIO pins, and a micro‑SD slot.

Installing the OS

Prepare a 16 GB or 32 GB SanDisk micro‑SD card.

Download the official Raspbian Stretch Lite image (≈1.7 GB).

Write the .img file to the card using Win32DiskImager.

After flashing, the card shows a single boot partition (≈40 MB) on Windows.

Enable headless SSH

Create an empty file named ssh (no extension) in the boot partition.

Configure Wi‑Fi

Create wpa_supplicant.conf in the boot partition with the following content (replace with your SSID and password):

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="your_wifi_name"
    psk="your_wifi_password"
}

First boot

Insert the card into the Zero W, power it with a 5 V 1 A USB cable, and wait for the LED to become steady. Find the Pi’s IP address from your router.

Connect via SSH

Use an SSH client (e.g., PuTTY) to log in with username pi and password raspberry.

System optimisation

Replace the default apt sources with a faster mirror (e.g., USTC):

sudo nano /etc/apt/sources.list
# comment existing lines and add:
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/raspbian stretch main contrib non-free rpi

Update the Raspberry‑Pi repository list:

sudo nano /etc/apt/sources.list.d/raspi.list
# comment existing lines and add:
deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian stretch main ui

Run sudo apt-get update && sudo apt-get upgrade to apply updates.

Set the correct timezone with sudo dpkg-reconfigure tzdata (select Asia → Shanghai).

Enable SSH on boot via sudo raspi-config (Interfacing Options → SSH → Enable) or by adding /etc/init.d/ssh start before exit 0 in /etc/rc.local.

Install Nginx

Run the following commands to install and start the web server:

sudo apt-get install nginx
sudo /etc/init.d/nginx start
# optional: restart or stop with the same script

Visiting the Pi’s IP address in a browser shows the default Nginx page.

Expose the server to the internet

Use a tunnelling service such as Ngrok (or alternatives like frp) to forward the local port 80 to a public URL. Example (using the arm‑compatible Ngrok binary): ./ngrok_arm http 80 The service prints a public URL (e.g., http://zerow.ittun.com/) that can be accessed from anywhere.

Result

The Zero W runs a lightweight web server, reachable both on the local network and via the Ngrok tunnel, while consuming only ~250 MB of RAM and maintaining a CPU temperature around 37‑39 °C after days of operation.

Zero W size comparison
Zero W size comparison
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxRaspberry PiSSHSystem SetupngrokZero W
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.