Apt-Proxy Server
Introduction
apt-proxy is a program that caches the packages you download from the Internet, to your hard disk. Because apt-proxy behaves as if it were a HTTP server with a full copy of the repositories you select, you can access the packages from other computers on your network. If a package is not in the cache, apt-proxy automatically downloads and caches it. This can significantly decrease download bandwidth and installation time when you have to install the same packages repeatedly (i.e. an upgrade of multiple machines).
Installation
apt-proxy is available from the Universe archive. To install it, run this command from a terminal:
sudo apt-get install apt-proxy |
Configuring apt-proxy Server
Default settings
The first section of the apt-proxy configuration file, located at /etc/apt-proxy/apt-proxy-v2.conf, contains the default settings for the apt-proxy and its cache.
so we will edit /etc/apt-proxy/apt-proxy-v2.conf change:
;; Server IP to listen on
address = 127.0.0.1 |
To:
;; Server IP to listen on address = 192.168.1.84 ----> as of my configuration |
Then change the server port if you would like to:
;; Server port to listen on port = 9999 ----> i left it the same in my server |
Backends
apt-proxy has to know where to find remote repositories, which it refers to as backends. This is done via backend sections in /etc/apt-proxy/apt-proxy-v2.conf. A backend entry for Ubuntu may look like this:
[ubuntu] ;; Ubuntu archive backends = http://archive.ubuntu.com/ubuntu http://de.archive.ubuntu.com/ubuntu |
As you can see, it is possible to specify more than one server, separated by blank space. If the first server is down, apt-proxy tries to get the data from the second server and so on. Note: If the first server is up, but does not have a required file, apt-proxy will not fall back to a second server.You can also override values set in the [default-section. For instance, if you know that a special server takes very long to answer a request, you can increase the timeout value:
[ubuntu-slow] timeout = 60 ;wait 1 Minute backends = prot://some.very.slow.server.net/ubuntu-slow |
Note that you don’t specify versions of distributions in this file; by enabling Ubuntu, you gain the ability to proxy for all versions (Hoary, Breezy, Dapper etc). What is downloaded depends on what is configured in the sources.list file on each client.
My server is on Ubuntu 7.10 Gutsy Gibbon
Initializing apt-proxy
After changing the apt-proxy configuration file, restart apt-proxy and update the list by running the following:
$ sudo /etc/init.d/apt-proxy restart |
Importing apt Cache
Packages already downloaded with apt-get, are cached in /var/cache/apt/archives. These packages can be imported into the apt-proxy cache with apt-proxy-import from the current package list. aptitude update should be run prior to apt-proxy-import to get a fresh list as follows:
$ sudo aptitude update
$ sudo apt-proxy-import -r /var/cache/apt/archives
Note: In the current version of apt-proxy in the repositories, this might not work correctly. There is known bug apt-proxy-import doesn’t work for me at all.
Updating clients to use your proxy server
apt clients need the /etc/apt/sources.list file to be reconfigured to point to the new apt-proxy server instead of the outside world.
Configuration of sources.list may look like this:
deb http://APT-PROXY-SERVER:9999/ubuntu/ jaunty main restricted universe multiverse deb-src http://APT-PROXY-SERVER:9999/ubuntu/ jaunty main restricted universe multiverse deb http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-updates main restricted universe multiverse deb-src http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-updates main restricted universe multiverse deb http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-proposed universe main multiverse restricted deb-src http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-proposed universe main multiverse restricted deb http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-security main restricted universe multiverse deb-src http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-security main restricted universe multiverse deb http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-backports main restricted universe multiverse deb-src http://APT-PROXY-SERVER:9999/ubuntu/ jaunty-backports main restricted universe multiverse deb http://APT-PROXY-SERVER:9999/ubuntu-partner/ jaunty partner deb-src http://APT-PROXY-SERVER:9999/ubuntu-partner/ jaunty partner |
ofcourse you will replace APT-PROXY-SERVER with your server hostname.
Now the client should go for it now and use your aptproxy server:-
$ sudo apt-get update $ sudo apt-get upgrade |