Apt-Cacher-NG on Ubuntu

Apt-Cacher-NG is an apt proxy. It caches the packages you download locally each time you update your system.
Why bother you might ask? Well, if you have multiple computers using the proxy, you save on bandwidth by not having to download the same packages twice, which also saves you time updating. In general, this is best implemented when Apt-Cacher-NG runs on a central server. Apt-Cacher-NG also has a number of nice options, accessed via a web interface, which allow you to tally usages, scan and add packages, and more.
I should mention that this HowTo was tested on Ubuntu 10.10 Server. It should work with minimal editing for other Ubuntu releases, Debian and other Debian based distros, though no promises.
Now, down to the meat!
Install Apt-Cacher-NG using apt
sudo apt-get install apt-cacher-ng
Once that process is finished, you should be able to open up http://server_IP:3142 in a web browser. You should be presented with a page like the one below.
Next, we simply follow the instructions to send our Apt requests through the server. The easiest way to do this is to set the server as a proxy (though you can also edit each sources.list entry, like it says above). You need to do this for every machine you want to access the proxy, which should include the machine itself (in which case you can use “localhost” as it’s IP below).
To do this, open up your apt config with Nano in a Terminal (Applications>Accessories>Terminal)
sudo nano /etc/apt/apt.conf
Edit it to add the following line, taking care to ensure it’s exactly the same as what I have here (other than changing the IP address).
Acquire::http { Proxy “http://server_ip:3142“; };
Hit CTRL+X, then Y, followed by Return to save and close the file.
You should then try to update your update definitions, to ensure everything’s working as it should
sudo apt-get update
If you get no error messages, congrats, you’ve set it up correctly! If you do, have a look back over the steps to make sure you’ve done everything right. As always, leave a comment if you’re having difficulty, and I’ll do my best to help.

Leave a Comment