How to Set Up a Local APT Caching Proxy for Your Home Lab

Running updates across a dozen Debian or Ubuntu-based VMs and containers means each one independently downloads the same packages from the internet, e…

Running updates across a dozen Debian or Ubuntu-based VMs and containers means each one independently downloads the same packages from the internet, even when they’re pulling identical files moments apart. Setting up an APT caching proxy for your home lab eliminates this redundancy, storing packages locally after the first download so every subsequent machine pulls from your own network instead of the internet.

What Is apt-cacher-ng?

apt-cacher-ng is a caching proxy specifically built for Debian and Ubuntu’s APT package system. It sits between your homelab machines and the internet, transparently caching downloaded .deb packages so that when a second machine requests the same package, it’s served instantly from your local cache instead of being downloaded again from a remote mirror.

Why This Matters for a Homelab

If you’re running several Debian or Ubuntu-based VMs and containers (which, given how many guides in this series use Debian/Ubuntu as their base, is likely the case for many homelab setups), each one currently downloads identical base packages and common dependencies independently. A local caching proxy means the first machine to update pulls packages from the internet as normal, but every subsequent machine gets the same packages served locally at your full internal network speed.

Installing apt-cacher-ng

On a dedicated VM or container that will act as your caching proxy:

sudo apt update
sudo apt install apt-cacher-ng -y

The service starts automatically after installation, listening on port 3142 by default.

Verifying the Service Is Running

sudo systemctl status apt-cacher-ng

Access the built-in status page from a browser to confirm it’s operational:

http://your-proxy-ip:3142/acng-report.html

Configuring Client Machines to Use the Proxy

On each Debian or Ubuntu-based machine you want to benefit from caching, create a configuration file pointing APT at your proxy:

sudo nano /etc/apt/apt.conf.d/02proxy

Add:

Acquire::http::Proxy "http://your-proxy-ip:3142";

Save the file — no restart is needed, since APT reads this configuration fresh on every run.

Testing the Cache Is Working

Run an update on your first configured client:

sudo apt update && sudo apt upgrade

Then check the same on a second client machine — package downloads for anything already cached from the first machine should now complete noticeably faster, served from your local network instead of the internet.

Monitoring Cache Usage

The apt-cacher-ng status page shows cache statistics, including how much data has been served from cache versus fetched fresh from the internet, giving you a concrete sense of how much redundant downloading the proxy is actually preventing across your homelab.

Configuring Cache Storage Limits

By default, apt-cacher-ng caches packages indefinitely, which can accumulate significant disk usage over time as package versions change. Adjust cache expiration settings in /etc/apt-cacher-ng/acng.conf if you want to periodically clear out older, no-longer-relevant cached packages rather than letting the cache grow unbounded.

Using It for Proxmox Container Templates Too

If you’re regularly deploying new LXC containers or cloning cloud-init VM templates , pointing those fresh deployments at your caching proxy from the start means even brand-new machines benefit immediately from packages your existing homelab has already cached, rather than starting from a completely cold cache every time.

Combining with Unattended-Upgrades

Since automated security updates () run independently across every machine, a caching proxy specifically reduces the redundant bandwidth and time those automated updates would otherwise consume when multiple machines happen to check for and apply the same security patches around the same time.

Final Thoughts

Setting up an APT caching proxy for your home lab is a small, one-time configuration that pays off continuously as your homelab grows to include more Debian or Ubuntu-based machines. Beyond the bandwidth savings, the noticeably faster update speed across your fleet of VMs and containers makes routine maintenance significantly less tedious.

Related Posts

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *