Cache APT
Utilité ?
apt-cacher-ng est un système de cache pour les paquets APT. Il permets donc d'avoir un cache local des paquets APT au sein d'un réseau défini. L'idée étant de ne pas surcharger les miroirs de votre distribution.
C'est particulièrement utile dans 2 situations: 1. peu de bande passante disponible 2. pas assez de volumétrie disponible pour héberger un miroir complet
Installation
L'installation se fait simplement via apt :
# apt install apt-cacher-ng
Configuration du serveur
Voici un exemple de configuration pour une distribution Debian :
# cat <<EOF > /etc/apt-cacher-ng/acng.conf
CacheDir: /var/cache/apt-cacher-ng
LogDir: /var/log/apt-cacher-ng
SupportDir: /usr/lib/apt-cacher-ng
Port:3142
BindAddress: 192.168.1.2
PassThroughPattern: .* # this would allow CONNECT to everything
Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
Remap-secdeb: security.debian.org security.debian.org/debian-security deb.debian.org/debian-security /debian-security cdn-fastly.deb.debian.org/debian-security ; deb.debian.org/debian-security security.debian.org cdn-fastly.deb.debian.org/debian-security
# http://192.168.1.2:3142/acng-report.html
ReportPage: acng-report.html
ExThreshold: 4
FollowIndexFileRemoval: 1
LocalDirs: acng-doc /usr/share/doc/apt-cacher-ng
EOF
Il faut ensuite redémarrer le service (et vérifier son état) :
# systemctl restart apt-cacher-ng.service
# systemctl status apt-cacher-ng.service
● apt-cacher-ng.service - Apt-Cacher NG software download proxy
Loaded: loaded (/lib/systemd/system/apt-cacher-ng.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-06-30 10:53:57 CEST; 2s ago
Main PID: 456005 (apt-cacher-ng)
Tasks: 1 (limit: 8754)
Memory: 2.0M
CPU: 43ms
CGroup: /system.slice/apt-cacher-ng.service
└─456005 /usr/sbin/apt-cacher-ng -c /etc/apt-cacher-ng ForeGround=1
Jun 30 10:53:57 home systemd[1]: Starting apt-cacher-ng.service - Apt-Cacher NG software download proxy...
Jun 30 10:53:57 home systemd[1]: Started apt-cacher-ng.service - Apt-Cacher NG software download proxy.
Configuration des clients
Pour les clients, il faut ajouter une configuration dans la configuration apt :
# cat <<EOF > /etc/apt/apt.conf.d/99proxy
Acquire::http { Proxy "http://192.168.1.2:3142"; }
EOF
Utilisation
L'utilisation est totalement transparente !