This is an old revision of the document!
Set Up and Ubuntu APT Cache
The apt-cacher-ng looks to be a self container apt caching server. Basically the apt cacher stores all the relevant apt update and upgrade related files and and acts as a proxy server to multiple clients. A handy feature to improve speed and reduce Internet bandwidth where a virtual machine server is used with multiple clients. There is another package called apt-cacher but it depends upon the installation of a separate webserver.
There is also APT-mirror that retrieves all packages from the specified public repository(s). Where as apt-cacher only retrieves each package when called and stores for subsequent use by other clients. APT caching looks the way to go and apt-cacher-ng the best overall option. I installed apt-cacher-ng on the VM server, not a VM client. The clients are setup to obtain their apt updates and upgrades via the server.
The LinuxHelp web page, How To Set up an Apt-Cache Server using "Apt-Cacher-NG" in Ubuntu 16.04 Server, provide a good description of how to setup. It is reasonably straight forward. I suggest the use of “sudo systemctl restart apt-cacher-ng”, as opposed to the old fashion “sudo /etc/init.d/apt-cacher-ng restart”.
If the non-default Cache directory is not set up correctly the program defaults to “/var/cache/apt-cacher-ng”. This quirk is covered in How to change the directory of the apt-cacher-ng downloaded packages" in Ubuntu Xenial.
Links to the Apt-Cacher NG home page and Apt-Cacher-NG User Manual.
- To access apt-cacher-ng web page: “http://192.168.1.1:3142”
- The configuration file is
sudo vim /etc/apt-cacher-ng/acng.conf
- The default cache directory is:
/var/cache/apt-cacher-ng
and can be changed in the configuration file. - The default log directory is:
/var/log/apt-cacher-ng
and can be changed in the configuration file. - The clients can access apt-cacher-ng cache by adding the following line into the new file:
sudo vim /etc/apt/apt.conf.d/02proxy
,Acquire::http::Proxy "http://192.168.1.1:3142";
There is an issue with use of apt-cacher and SSL/TLS repositories. A good reference is from packagecloud:blog: Using apt-cacher-ng with SSL/TLS. The apt-cacher-ng manual section 8.3 8.3 Access to SSL/TLS remotes (HTTPS) is source reference. The general clients access noted above “sudo vim /etc/apt/apt.conf.d/02proxy
, Acquire::http::Proxy "http://192.168.1.1:3142";
” will not function with https secured repositories. Instead each repository will need to be manual set as http to apt-cache-ng with aptchahe-ng accessing the https repositories and caching them locally. When performing a sudo apt update
note the repository errors and find the repository within repository files in the sub-directory /etc/apt
. Below is some I have found:
sudo vim /etc/apt/sources.list.d/nodesource.list
; change:deb https://deb.nodesource.com/node_10.x bionic main
todeb http://https///deb.nodesource.com/node_10.x bionic main
deb-src https://deb.nodesource.com/node_10.x bionic main
todeb-src http://https///deb.nodesource.com/node_10.x bionic main
For do-release-update
change sudo vim /etc/update-manager/meta-release