89 lines
2.4 KiB
Markdown
89 lines
2.4 KiB
Markdown

|
|
|
|
L'objectif de cet article est de déployer un cache pour apt. Cette solution a été testée en tant que serveur avec:
|
|
- Raspberry Pi 2 - Debian / Raspbian 10.3
|
|
|
|
En tant que client avec :
|
|
- Raspberry Pi 2 - Debian / Raspbian 9.11
|
|
- Raspberry Pi 2 - Debian / Raspbian 10.3
|
|
- Raspberry Pi 4 - Debian / Raspbian 10.3
|
|
- PC - MX Linux 19
|
|
|
|
Un cache apt permettra de "mettre en mémoire" les paquets téléchargés de manière automatique afin d'en faciliter le téléchargement si plusieurs demandes sont effectuées pour ces mêmes paquets.
|
|
|
|
On utilisera la solution `apt cacher`.
|
|
|
|
On pose comme hypothèse les informations suivantes :
|
|
|
|
**Serveur APT**
|
|
- nom du serveur APT : rpiapt01
|
|
- port du service APT : 3142
|
|
- réseau : 192.168.100.3/24
|
|
- Système d'exploitation : Raspbian 10.3 sur Raspberry Pi 2
|
|
|
|
# Déployer
|
|
```
|
|
# apt install apt-cacher-ng
|
|
```
|
|
|
|
## Configuration de apt-cacher
|
|
**Éditer** le fichier `/etc/default/apt-cacher` et mettre l'option AUTOSTART à 1 :
|
|
```
|
|
AUTOSTART=1
|
|
```
|
|
|
|
**Autoriser** tous les ordinateurs avec le paramètre `allowed_hosts` dans le fichier `/etc/apt-cacher-ng/acng.conf`. Par exemple, pour utiliser tout le monde :
|
|
```
|
|
allowed_hosts = *
|
|
```
|
|
|
|
**Rendre compatible** le protocole https :
|
|
```
|
|
PassThroughPattern: .*
|
|
```
|
|
|
|
Pour réduire l'utilisation aux postes d'un réseau spécifique :
|
|
```
|
|
allowed_hosts = 192.168.100.1/24
|
|
```
|
|
|
|
**Exécuter** le service `apt-cacher`
|
|
```
|
|
# service apt-cacher start
|
|
```
|
|
|
|
Si la connexion Internet passe par un proxy, **éditer** le fichier `/etc/apt-cacher/apt-cacher.conf` et modifier ces lignes :
|
|
```
|
|
http_proxy=hostname:port
|
|
use_proxy=1
|
|
http_proxy_auth=username:password
|
|
use_proxy_auth=1
|
|
```
|
|
|
|
```BASH
|
|
# systemctl enable apt-cacher-ng.service
|
|
# systemctl start apt-cacher-ng.service
|
|
```
|
|
|
|
## Configurer les postes clients
|
|
**Éditer** le fichier `/etc/apt/apt.conf.d/01proxy` et insérer la ligne suivante :
|
|
```
|
|
Acquire::http::Proxy "http:*192.168.100.3:3142";
|
|
```
|
|
|
|
**Purger** le cache apt et **mettre à jour** la liste des paquets :
|
|
```
|
|
$ sudo rm -rf /var/lib/apt/lists/*
|
|
$ sudo rm -rf /var/cache/apt/*
|
|
$ sudo apt update
|
|
```
|
|
|
|
## Biblio & crédits
|
|
Autres articles :
|
|
- https:*doc.ubuntu-fr.org/apt-cacher
|
|
- https:*help.ubuntu.com/community/Apt-Cacher-Server
|
|
- https:*geekflare.com/create-apt-proxy-on-raspberrypi/
|
|
- https:*www.tecmint.com/apt-cache-server-in-ubuntu/
|
|
|
|
Images :
|
|
- Schéma de principe de apt-cache-server - https:*doc.ubuntu-fr.org/apt-cacher - Wiki ubuntu-fr |