Setting Up an Ubuntu Mirror Cache on a Raspberry Pi with Nginx

Fahad Ahammed
7 min readSep 19, 2024

I have multiple Raspberry Pi’s and workstation running Ubuntu. I usually run Same Linux Distribution for all my SBC’s. They are now running Ubuntu 24.04 and all are connected Via Wifi. Whenever some updates in the software repository comes in, most of the cases, all of the Raspberry Pi’s need to download same things from the mirror.

To make it faster and efficient, I decided to create an Ubuntu Mirror Cache in one of the SBC to speed up software installations and updates, setting up a local mirror cache can dramatically reduce download times and minimize bandwidth usage. In this article, I will walk through the steps to configure Nginx to cache only .deb package files while ensuring your repository metadata stays up-to-date for the latest upgrades. This is an ideal project for Raspberry Pi enthusiasts who want to enhance their local network’s efficiency with the power of opensource.

Nginx for caching for deb packages for Ubuntu APT

Result of the Setup

Let us have a look at when not cached and cached are creating the difference.

I wanted to install ZFS utils.

# Not Cached
# apt update
Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease
Hit:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease
Hit:3 http://ports.ubuntu.com/ubuntu-ports noble-backports…

--

--

Fahad Ahammed

A learner of Cloud, Linux, and Programming with 7+ years of experience in the related field sharing my day-to-day stories.