Overview

This is a simple HTTP redirector for APT

More background at http://www.dnorth.net/2013/09/25/apt-and-http-redirects/

It's intended for use when your organisation has a local mirror which
is only visible from inside their network. You want your portable device
(laptop, tablet, ...) to use that when you're at work, and not when
you're elsewhere with no access to it.

You need to:

0) Pick a URL for your director, such as http://mirrordirector.example.com

1) Mount director.py to handle all requests to that URL. For Apache 2, a
   virtualhost with something like this should do the job:

        DocumentRoot /srv/www/mirrordirector.example.com
        AddHandler cgi-script .py

        <Directory /srv/www/mirrordirector.example.com>
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-f
        # director.py gets the requested URI from REQUEST_URI environment
        # variable. Don't try and pass it through here as the encoding of
        # some characters, notably +, gets messed up
        RewriteRule .* director.py [L]
        </Directory>

2) Change the Debian entries (except for Debian security) in your APT
   sources.list to use mirrordirector.example.com.

3) Test by running apt-get update. There should be no errors