apt-cacher-ng on Debian Squeeze

apt-cacher-ng is an apt proxy which can be used in a Local Area Network where you have multiple Debian machines; they can be stable, testing, sid, experimental ones and that's not a problem at all. The server host which runs apt-cacher-ng proxy service will maintain a cache with all the packages that were requested by clients for being installed; when a different client requires the same package, previously fetched from the internet because another host needed it, it now can download that package from the proxy instead of wasting internet bandwidht.

Server-side

Once you have installed the proxy ..

# apt-get install apt-cacher-ng

we can configure it editing it's configuration file ..

# nano /etc/apt-cacher-ng/acng.conf

The rilevant options to be modified are, in my opinion, these ..

CacheDir: /home/apt-cacher-ng/cache
LogDir: /var/log/apt-cacher-ng
Port:3142

If you are going to change the default CacheDir as i did, remember to set permission on that dir too, like this:

# chown -R apt-cacher-ng:apt-cacher-ng /path/to/CacheDir

The binding address can be altered too but that's not strictly necessary.

Finally address a restart to the service:

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

In order to test if apt-cacher-ng is working you can download some package the same way you always did with apt and check the "CacheDir" for changes (it should now be populated). Finally you should able to browse http://localhost:3142 where you will find some informations and the "Statistics report and configuration page" link.

Client-side

From the client prospective there is not much work todo: if you have already visited the aforementioned link on your server you'll just have found instructions.

Two are the ways to configure apt in your client machines: use a conf file or rewrite the sources.list.

1) The easy way is to touch a..

# touch /etc/apt/apt.conf.d/02proxy

and paste a one liner configuration in it like this:

Acquire::http { Proxy "http://192.168.1.1:3142"; };

replacing the ip address and port settings accordingly to your environment.

2) The still easy but not so fast way is to change your sources.list configuration file and append the proxy address portion to each and every configured repository, like this:

deb http://ftp.debian.org/debian stable main contrib non-free

deb http://192.168.1.1:3142/ftp.debian.org/debian stable main contrib non-free

That should be enough to go.