Share this post
FaceBook  Twitter  
Contents[Hide]

1. Introduction

Approx is a proxy server for Debian archive files. Having such a service within your LAN with multiple Debian like systems will provide you with number of benefits such as update speed since any update package needs to be downloaded only once. This will also lower down Internet download usage requirements, etc. This article will describe a process of approx setup for Ubuntu Linux.

2. Installation

As any other installation from standard Ubuntu repository, installation of the approx apt proxy server is a fairy simple process.  Install the approx apt proxy server with:

$ sudo apt-get install approx

The above command will also install all prerequisites including Internet superserver inetd, which is used to invoke the approx server.

Approx is by default using port 9999. Once you finish with installation you can confirm whether the server is up and running with the netstat command and check for port 9999.

$ netstat -ant | grep 9999
tcp        0      0 0.0.0.0:9999            0.0.0.0:*               LISTEN

3. Changing default port

The first customization you can do is to change default 9999 approx listening port to some other port. Simply edit /etc/inetd.conf config file and enter your desired port such as 80:

80            stream  tcp     nowait  approx  /usr/sbin/approx /usr/sbin/approx

Once you make this change, restart inetd superserver to apply the changes:

$ sudo /etc/init.d/openbsd-inetd restart
 * Restarting internet superserver inetd                                   [ OK ]

Another and perhaps easier way to change the approx port number is to use the dpkg-reconfigure command:

$ sudo dpkg-reconfigure approx 

4. Setting up repositories

Approx has only one configuration file and that is /etc/approx/approx.conf. This is also the place where you can define Ubuntu repositories for your clients. Login to your Ubuntu client and extract all current repository sources from /etc/apt/sources.list file. Please note, this is an example, as your sources will be different and the below command may not work for you if you had altered the original Ubuntu sources.list file.

$ grep -E "^[^#]" sources.list | cut -d " " -f2 | uniq 
http://au.archive.ubuntu.com/ubuntu/
http://security.ubuntu.com/ubuntu

 The output of the above command extracts your current sources list mirrors. Simply copy the above lines and paste them into /etc/approx/approx.conf. Prefix each relevant mirror with:

ubuntu http://au.archive.ubuntu.com/ubuntu/
ubuntu-security http://security.ubuntu.com/ubuntu

Once you set all mirrors in the approx config restart approx by restarting the inetd superserver:

$ sudo /etc/init.d/openbsd-inetd restart
 * Restarting internet superserver inetd                                   [ OK ]

For you convenience, here are some generic mapping you can use. Please note, it is always good to use the closest mirror.

4.1. Ubuntu

ubuntu    http://archive.ubuntu.com/ubuntu
ubuntu-extras    http://extras.ubuntu.com/ubuntu
ubuntu-partner    http://archive.canonical.com/ubuntu
ubuntu-security    http://security.ubuntu.com/ubuntu

4.2. Debian

debian    http://ftp.debian.org/debian
debian-security    http://security.debian.org/debian-security

5. approx Client Setup

Now, that we have setup our approx server, it is time to configure the clients station. You need to configure your local DNS if you wish to use some hostname associated with the approx's IP address. Or, simply, edit local /etc/hosts file and add the following line:

10.1.1.10            approx

where 10.1.1.10 is an IP address of your approx server. Once done, edit client's /etc/apt/sources.list to point to your approx:9999 apt proxy server.  Your new sources.list file may look like this:

deb http://approx:9999/ubuntu/ precise main restricted
deb-src http://approx:9999/ubuntu/ precise main restricted
deb http://approx:9999/ubuntu/ precise-updates main restricted
deb-src http://approx:9999/ubuntu/ precise-updates main restricted
deb http://approx:9999/ubuntu/ precise universe
deb-src http://approx:9999/ubuntu/ precise universe
deb http://approx:9999/ubuntu/ precise-updates universe
deb-src http://approx:9999/ubuntu/ precise-updates universe
deb http://approx:9999/ubuntu/ precise multiverse
deb-src http://approx:9999/ubuntu/ precise multiverse
deb http://approx:9999/ubuntu/ precise-updates multiverse
deb-src http://approx:9999/ubuntu/ precise-updates multiverse
deb http://approx:9999/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://approx:9999/ubuntu/ precise-backports main restricted universe multiverse
deb http://approx:9999/ubuntu precise-security main restricted
deb-src http://approx:9999/ubuntu precise-security main restricted
deb http://approx:9999/ubuntu precise-security universe
deb-src http://approx:9999/ubuntu precise-security universe
deb http://approx:9999/ubuntu precise-security multiverse
deb-src http://approx:9999/ubuntu precise-security multiverse

After you had altered /etc/apt/sources list run update to confirm correctness of your settings:

$ sudo apt-get update

6. Conclusion

Having an apt proxy server on LAN has its own benefits. There are also various proxy servers doing the same or similar type of job such as apt-cacher or apt-proxy. For more configuration options for approx visit:

$ man approx

Partners

Who are we?

LinuxCareer.com is not affiliated with any local or international company, nor is it a recruitment or employment agency. We specialise in Linux based careers and closely related Information Technology fields by providing careers advice and latest employment opportunities.

JOIN LINUXCAREER

You can also get involved in the LinuxCareer project by participating on our FORUM or SUBMITTING A LINUX ARTICLE. We offer a range of privileges to our authors and good company.