Setting up apt proxy Server Approx on Ubuntu Linux


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.


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* LISTEN

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 

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

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:


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.





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:            approx

where 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


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