Making a apt-get proxy

Why a Proxy

I was to update a couple of servers in my home lab and I could see that even with a 100/20Mbit  it will still take a some minuets to do the apt-get Update & apt-get upgrade.  And 3min x10 if I had to manual to do this a pain if it was in a bigger environment would take ages.

Well i could use puppet to control this in its manifest. But for educational purposes I have chosen to make a server for this.

I have chosen apt-cacher-ng for my new addition to my server park. I have server for each service that I want to run in my small lab network.

Installation

First installation of the Debian package

apt-get install apt-cacher-ng

There is a little of configuration after the installation of the software but not much. The documentation states that is it actually not necessary.

Configuration of the server

Using nano the configurations is made.

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

Setting up the cache directory.

  • Default /var/cache/apt-cacher-ng

I just leave at it is same as the log folder at

  • Default /var/log/apt-cacher-ng

Setting the bind address to 0.0.0.0 specifying that it now only will listen to IPv4.

  • BindAddress: 0.0.0.0

Repositories:

I’m only using Debian so in this part all the none Debian is commented out.

  • Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian
  • Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu
  • Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol
  • #Remap-cygwin: file:cygwin_mirrors /cygwin
  • #Remap-sfnet: file:sfnet_mirrors # ; file:backends_sfnet
  • #Remap-alxrep: file:archlx_mirrors /archlinux # ; file:backend_archlx # Arch Lin$
  • #Remap-fedora: file:fedora_mirrors # Fedora Linux
  • #Remap-epel: file:epel_mirrors # Fedora EPEL
  • #Remap-slrep: file:sl_mirrors # Scientific Linux

VerboseLog:

  1. 0 to store only type, time and transfer sizes
  2. 1 -> client IP and relative local path are logged too

VerboseLog: 1

PidFile:

Store the pid of the daemon process therein
PidFile: /var/run/apt-cacher-ng/pid

ExTreshold:

Days before considering an unreferenced file expired (to be deleted). if the value is set too low and particular index files are not available for some days (mirror downtime) there is a risk of deletion of still useful package files. In this case 4 days should be appropriate
ExTreshold: 4

Client Configurations

  1.  A new installation of debian 7.7 how fast will it get the packages
  2. What is the difference in update speeds compare between two identical Debian VMs

New Installation with proxy

Starter the installations procedures normally by choosing the languished  and keyboard settings. Making a partitions and starting the installation. The installation media is a net install image on 220MB so it has to access the Internet normally before it can in install packages missing in the installation.

The installation roughly took 10 min and 8 -12 sec to download  121 package.
A fine result. Okay my connection is rather quick but the log on the apt-cache server tells me that it is indexing the packages and what are accessed on the server.

apt-cache logUsing the proxy in the installation procedure you need to add the mirror manual.  Screen asking me to add a hostname or mirror appear. Deleting the pre-entered “mirror” and replacing it with the server ip of my apt-proxy server eg 192.168.20.3:3142 and hitting enter to continue. Now it will ask if it is behind a proxy and I am not so now and the installation begins.

Proxy vs. none-proxy update

First i´m going to setup the proxy configurations on the server that is to use the proxy

  1. Create a file called 02proxy
  2. edit with nano or vi and add “Acquire::http { Proxy “http://192.168.20.3:3142″; };” without ” ” and save it

That is all the client needs for using the apt-proxy service or insert in the /etc/apt/sources.list the giving input as belowsource list

The upgrade test. How many MB in what sec?

need packages

  • TEST2 server 48MB 2s
  • TEST3 server 48MB 1m47s

There were a minor difference in upgrading time in 1m51s taking with a timer.

apt-cacher-ng helps me in fast deployments and updates

 

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.