This is nothing really new, but definitely worth tracking because it just make sense and works fine.

If you either virtualise or have otherwise many Debian / Ubuntu / Centos / Fedora based servers and workstations and want to keep them updated regularly, you do this over the internet for each and every instance. This utilises bandwidth and takes time to download particularly if you don’t have a some big internet connectivity.

The principle is that you setup a proxy server for apt or yum which caches and serves on duplicate request the packages and therefore you will save time and bandwidth.

The first device fetching the package will trigger the proxy to cache it and the next instance will receive the cache package from the proxy. This will reduce the used bandwidth and volume of the internet line and speed up the update due to using a local available cache.

I also want to write something about another tool for Debian and Ubuntu named Aptly which allows to run controlled internal repositories mirrored from the official repositories but with custom versioning and point in time snapshots, which is most likely the better way a large organisation would handle updating Linux servers. I hope to get to this soon.

I explain here how to install apt-cacher-NG under Debian (it works the same under Ubuntu) while the clients can be Debian / Ubuntu  based or Fedora / Centos based. Apt-cacher-NG handles both types of packages as a proxy.

How to install apt-cache-NG in Debian or Ubuntu:

In my case the debian server running apt-cacher-ng has the IP Address

sudo apt-get install apt-cacher-ng

Once the installation completed check the config file for the right settings as needed.

vi /etc/apt-cacher-ng/acng.conf

Modify as needed:

CacheDir: /var/cache/apt-cachepoweroffr-ng
LogDir: /var/log/apt-cacher-ng
#The port to listen on
# will listen to each and every IP else you can limit it
#this is needed if you like to have a html page for the statistics as in the screenshot later on.
ReportPage: acng-report.html
#make sure this is not commented out
PidFile: /var/run/apt-cacher-ng/pid

I left the remap entries alone, it worked out of the box without any modification, but there is a manual available if there is a need to modify it.

Restart apt-cacher-ng

service apt-cacher-ng restart

You can now open the webinterfaces for apt-cacher-ng.    #for a config page #for the statictis page

Client Config:

For all client config counts that you need to make sure the proxy will be available when running updates. Else they will fail at all since the proxy will be hard coded. To remove the proxy and fetch from the internet direct you will need to # comment the entry out.


Debian / Ubuntu based (APT/deb)

To activate, edit or create the file /etc/apt/apt.conf

vi /etc/apt/apt.conf
Acquire::http { Proxy ""; };

Then run normal apt-get update;apt-get upgrade

Centos / Fedora based (YUM/rpm)

To activate, edit the file /etc/yum/yum.conf and insert:

vi /etc/yum.conf

Then run

yum update


As per the following stats screenshot and a few update sessions over the last few days, the reduction is sizeable. The Misses are the newly to be fetched packages while Hits is the duplicate data served from cache.

Update: 2017-05-21
There is a great Post by packagecloud describing apt-cacher handling and how to resolve https repo issues.

%d bloggers like this: