I've decided to write this year quite often on Ubuntu, currently Ubuntu 7.10 (Gutsy Gibbon). Since I like my instructions to be reproducible I often have to reinstall Ubuntu from scratch. And because this means that I have to download over 200 MB of additional packages over a slow connection, I had decided to set up my development computer, running Windows XP, as a proxy. In the evening I decided to look into it, and it turned out to be a piece of cake to set up the Apache web server as a proxy.
My development computer is running a quite outdated version of the Apache web server:
Server version: Apache/1.3.33 (Win32)
Server built: Oct 28 2004 07:27:29
First, I edited the virtual hosts file (see Installing and configuring Apache on Windows XP). I added to the first virtual hosts section, the one that I use to access a local version of this web site, the following lines:
ProxyRequests Off
CacheRoot "E:/usr/john/Downloads/ubuntu-cache"
CacheSize 524288
CacheGcInterval 0.5
ProxyPass /ubuntu/ http://ubuntu.media.mit.edu/ubuntu/
ProxyPassReverse /ubuntu/ http://ubuntu.media.mit.edu/ubuntu/
This way I get a reverse proxy with a cache size of 524288 kbytes (512 Mbytes), and a request for /ubuntu/ will be handled by http://ubuntu.media.mit.edu/ubuntu/. Since I added these lines to the first virtual host, I can also get to http://ubuntu.media.mit.edu/ubuntu/ by using the IP address of my development computer, in other words: http://192.168.1.100/ubuntu.
Since I am using mod_proxy I have to make sure that the Apache web server does load this module. I did so by removing the # character from the very start of two lines. One from line 187:
LoadModule proxy_module modules/mod_proxy.so
and another from line 232:
AddModule mod_proxy.c
After I had modified those two files I restarted the Apache web server as follows:
C:\>net stop apache
The Apache service is stopping.
The Apache service was stopped successfully.
C:\>net start apache
The Apache service is starting.
The Apache service was started successfully.
When I entered http://192.168.1.100/ubuntu I got what I expected: the index of /ubuntu/ at ubuntu.media.mit.edu.
For the next step I needed to reinstall Ubuntu one more time the slow way, so the cache could be filled up with the packages required to update my Acer Aspire notebook after installation of Ubuntu 7.10.
After the installation of Ubuntu was finished, and the notebook was rebooted, I logged in and modified /etc/apt/sources.list:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
sudo gedit /etc/apt/sources.list
I selected the host name and path in the first URL (mx.archive.ubuntu.com/ubuntu/) and replaced all occurences with the IP address of the computer running the Apache web server, followed by the path (192.168.1.100/ubuntu).
Then I made sure to resynchronize the package index files from their sources:
sudo apt-get update
Which caused files and folders to appear inside the cache directory of my Windows XP computer. So something was happening, and it looked good.
Next I started the Update Manager, which reported 149 updates to be installed, a now familiar number to me. I clicked on the Install Updates button, entered my password, and the update process began, extending the cache more and more.
When the update was finished, I did another installation of Ubuntu, modified /etc/apt/sources.list, resynchronized the package index files - which took a short time now - and started the Update Manager. This time it took about half a minute to download 149 updates; mission accomplished.