Quick Contact

Contact our team on
01788 298450
Or use our callback by entering your number here for an instant response

Related Items

No related items
Using apt-proxy to reduce bandwidth and increase speed
Articles & Information - Tech Talk

What is apt-proxy?

apt-proxy is a program (daemon) that stores regularly downloaded debian and debian-based (Ubuntu) package files. This is useful when there are multiple debian systems on the same network.  Any updates pulled down for one machine from the Internet will be made available to all machines locally which reduces required bandwidth and increases speed. 

How do I set up the apt-proxy server?

To install the package: "apt-get install apt-proxy"  then check / modify the configuration. Recent versions use  the configuration file:  /etc/apt-proxy/apt-proxy-v2.conf

This file contains sections for each type of  package source which enables caching of different flavours (Debian, Ubuntu etc) and also different sources (backports, security etc).

A section looks like this:

[debian]
backends =
        http://debian.virginmedia.com
        http://ftp.uk.debian.org/debian
min_refresh_delay = 1d
This has been set up to use the Virgin Media local Debian cache then the main UK debian site. As many backends as needed can be specified in order of preference.

There are many examples in the default configuration file which allow it to work out of the box. However, it is always worth learning some local caches for your country, region or connection provider.

Some un-documented but useful additions are: 

[backports]
backends =
        http://backports.debian.org/debian-backports
min_refresh_delay = 1d

(Formerly backports.org)

apt-proxy will automatically work out which particular version you have based on the client configuration so you do not need to specify configuration sections for lenny, squeeze and so on.

There are other configuration settings but generally these can be left as default. The most notable setting to be aware of is the  server port to listen on. By default, this is set to: "port = 9999".

Once the configuration has been updated, restart apt-proxy: " /etc/init.d/apt-proxy restart"
 

How do I set up client systems to use apt-proxy server

Edit your sources file ( /etc/apt/sources.list) and comment out all of the existing sources with a # symbol. 

You will need to change the example servername to the IP address or hostname of the machine you have set up for apt-proxy.You will also need to know the port that the server is configured against. By default, this is 9999.

Here are some example client configuration:

Debian Lenny using apt-proxy

# apt-proxy for Lenny
deb http://apt-proxy:9999/debian lenny main contrib non-free
deb-src http://apt-proxy:9999/debian lenny main contrib non-free
deb http://apt-proxy:9999/security lenny/updates main contrib non-free
deb http://apt-proxy:9999/backports lenny-backports main

Debian Squeeze using apt-proxy

# apt-proxy for Squeeze    
deb http://apt-proxy:9999/debian squeeze main contrib non-free
deb-src http://apt-proxy:9999/debian squeeze main contrib non-free
deb http://apt-proxy:9999/security squeeze/updates main contrib non-free
#deb http://apt-proxy:9999/backports squeeze-backports main

Ubuntu Maverick using apt-proxy

deb http://apt-proxy:9999/ubuntu maverick main restricted universe multiverse
deb http://apt-proxy:9999/ubuntu maverick-security main restricted universe multiverse
deb http://apt-proxy:9999/ubuntu maverick-backports main restricted universe multiverse
deb http://apt-proxy:9999/ubuntu maverick-updates main restricted universe multiverse

Debian Etch using apt-proxy

Debian Etch needs to be treated differently as the repository has been migrated from the main deb servers to the archive. In order to make this work, we need to be creative. The suffix of the deb url specifies which section in the apt-proxy is used for this request. We usually use "/debian" for standard releases. Since the backends under the [debian] section no longer support Etch, we need to add another one with a different suffix as follows:

[archive]
timeout = 10
min_refresh_delay = 1d
backends =
http://archive.debian.org/debian/

Then use the following line in your sources.list:

deb http://apt-proxy:9999/archive etch main contrib non-free 

Making use of the new apt-proxy configuration

Once the sources have been set up,  run "apt-get update" to load the indexes via the proxy then  "apt-get upgrade" to update or install packages . These may need to be pre-fixed with "sudo" on ubuntu.

The first time a package is loaded in to the proxy, you will probably not experience any benefit. However, on the second and subsequent systems, the performance will be increased dramatically.

Troubleshooting

Debugging levels can be set within the configuration file. The working output can be found in the logfile:   /var/log/apt-proxy.log

Due to the way apt works, there are few useful errors at the client if there are server issues. If you find long timeouts whilst waiting for headers at the client, it is likely that you have a misconfigured backend on the apt-proxy. These can be tricky to spot so careful examination may be needed.

Example problems 

Error:

Err http://apt-proxy lenny Release.gpg
  Bad header line
Err http://apt-proxy lenny/main Translation-en_GB
  Bad header line
Err http://apt-proxy lenny/contrib Translation-en_GB
  Bad header line
0% [Waiting for headers]

Cause: This is caused by a backend set up  at the client that does not exist at the server.

Error:

 Err http://apt-proxy lenny Release.gpg
  Could not resolve ‘apt-proxy’

Cause: The servername is not correct

Error:

Err http://apt-proxy lenny Release.gpg
  Could not connect to apt-proxy:9999  - connect (111 Connection refused)

Cause: Port number not correct or server not running on the host

Error:

 0% [Waiting for headers]

Cause: The requested distribution may not be valid or available via the backends configured.

Note:

At the time of writing, apt-proxy  is not available on Squeeze. The lenny package can be installed if required.

Alternatives to apt-proxy

apt-cacher  is a newer and more frequently updated apt-proxy system and is directly client-compatible with apt-proxy. However, apt-cacher cannot manage different deb-based distributions simultaneously so multiple servers are needed to manage Debian and Ubuntu clients. 

 
 
Open Source Software Companies - UK
Opus Vision Limited T/A OpusVL Registered UK number 3905104
We are featured in the FreeIndex Software Development directory