The Linux Page

Add a cache to upgrade your LAN servers faster

Since I have several computers running Ubuntu, I like to have them up to date, but it always takes a bit of time to download the new packages. I think those should be downloaded only once and then shared between all my computers (I also run VPS which can benefit from this sharing.)

So, I decided to finally look into it and the simplest was to install apt-cacher-ng on my main server:

sudo apt-get apt-cacher-ng

That's it for the main server (from what I've read, at least, although I am thinking that maybe we need to tell apt-get to check that cache first even on the main system?)

Next, on each of the computers that you want to gather information from the outside enter a proxy definition like this:

# To create/open the file
vim /etc/apt/apt.conf.d/02proxy

# First a proxy (change IP address with your main server IP):
Acquire::http { Proxy "http://192.168.0.1:3142"; };

# Second, entries to skip the proxy if required (i.e. entries using HTTPS)
# Enter the domain name and then DIRECT, enter multiple separated by ';'
Acquire::http::Proxy { top-secret.example.com DIRECT; };

This will already work pretty well, but once in a while you will have to upgrade a file which requires more rights on the server side. This means you need to enter a user name and a password of someone who can run apt-get.

# Open the security.conf file
vim /etc/apt-cacher-ng/security.conf

# Edit the AdminAuth variable with your administrator name and password:
AdminAuth: james:bond

That edit will prevent the 500 Missing Content-Length errors you were seeing.