Ubuntu Server – Installing apt-cacher-ng as an APT proxy for downloading software packages

If you have several Ubuntu machines downloading packages over the internet you can use apt-cacher-ng as a proxy to cache these packages locally. This will save bandwidth and increase the speed with which machines get packages (once they have been cached). To set this up I will install  apt-cacher-ng on Ubuntu Server  and then configure my Ubuntu desktop machines to use  apt-cacher-ng as a proxy.

Having set a static IP address on my server installation I installed apt-cacher-ng as follows:

sudo apt-get update
sudo apt-get install apt-cacher-ng

Install nano and edit the apt-cacher-ng configuration file acng.conf:

sudo apt-get install nano
sudo nano /etc/apt-cacher-ng/acng.conf

I made the following change to acng.conf:


Note that acng.conf defines the cache directory as var/cache/apt-cacher-ng/_import – we will need to create this folder later on.

Restart apt-cacher-ng:

sudo /etc/init.d/apt-cacher-ng restart

Next we can move on to the setup of client machines – this requires configuring the server as a proxy and can be accomplished with the following command:

echo 'Acquire::http { Proxy "http://<server-ip>:3142"; };' | sudo tee

Make sure that you replace <server-ip> with the static IP address of your apt-cacher-ng server.

Now that the basic setup is complete there are a few additional steps to perform – the first of which is to import any packages that the server has downloaded into the apt-cacher-ng cache.

On the server create the _import directory for the apt-cacher-ng cache:

sudo mkdir /var/cache/apt-cacher-ng/_import

Copy packages from /var/cache/apt/archives to /var/cache/apt-cacher-ng/_import:

cd /var/cache/apt/archives
sudo cp *.* /var/cache/apt-cacher-ng/_import

Give apt-cacher-ng ownership of the /var/cache/apt-cacher-ng/ and /var/cache/apt-cacher-ng/_import directories:

sudo chown -R apt-cacher-ng /var/cache/apt-cacher-ng

From here we can complete our configuration using the apt-cacher-ng web based dashboard. Open a browser with the following URL:


Make sure that you replace <server-ip> with the static IP address of your apt-cacher-ng server:

Apt-cacher-ng dashboard

On the apt-cacher-ng dashboard scroll down and click the Import button:

Apt-cacher-ng import

Once the import is complete you can test that everything is working by downloading the same package from multiple clients. Using the Count Data button at the top of the apt-cacher-ng dashboard you will be able to monitor the transfer statistics:

apt-cacher-ng statistics


For configuration of mobile proxy clients such as laptops see: https://pricklytech.wordpress.com/2011/03/22/ubuntu-10-4-lucid-configuration-of-apt-cacher-ng-mobile-clients/



Ubuntu forum



6 thoughts on “Ubuntu Server – Installing apt-cacher-ng as an APT proxy for downloading software packages

  1. Thanks for this load of information, Mike. I am an absolute novice in Ubuntu (and similar Open OS) so these info both fascinate and challenge me into trying to learn more-and-more about this OS. You might see that I also have a wordpress blog (ezdapiton.wordpress.com) where I record my learning experiences with Ubuntu (or try to); I will link your site to mine for added info to anyone. .e.

    1. Glad that you found the info useful ezdapiton – part of the attraction of Ubuntu for me was the wealth of information that is available about it, that and the helpful folks on the Ubuntu forums 🙂 Thank-you for the link, much appreciated!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s