Setup squid-deb-proxy on trusty

Why squid-deb-proxy?

  • No editing of files on the client side.
  • Use zeroconf so that clients were "zero config"
  • Use an existing, solid proxy solution instead of writing a new tool.
  • Easy to set up for a typical Linux administrator.

Server Config

sudo apt-get install squid-deb-proxy avahi-utils

Now start the service bits:
sudo service squid-deb-proxy start

This will install the proxy server (which listens to port 8000 by default) and the avahi tools needed for the server to advertise itself on your network via zeroconf.

Client Config

sudo apt-get install squid-deb-proxy-client

Optional: For maximum efficiency you should set one machine to automatically download updates, so that when your other machines need it it's already in the cache. You can do this by going to System->Administration->Update Manager, then click on the "Settings..." button, in the Update tab set it to automatically download all the updates.

Caching 3rd Party Sources

By default the cache is set up to only cache official Ubuntu repositories. To add more you need to add them to the list of sources at /etc/squid-deb-proxy/mirror-dstdomain.acl. This is where you can add ppa.launchpad.net, or other services you might use. After making changes to this file, you must run sudo restart squid-deb-proxy in order for the changes to be effective.

Manual Config

If for some reason you do not want to use zeroconf (for network reasons or whatever), you can manually set a client to use the proxy by editing /etc/apt/apt.conf and adding the following stanza, (replace the 0.0.0.0 with the IP address of the server):

Acquire { 
 Retries "0"; 
 HTTP { Proxy "http://0.0.0.0:8000"; };
 };

Confirm it Works

First tail the log on the server so you can look at it: tail -F /var/log/squid-deb-proxy/access.log and then run an update on any machine that has the client installed; the log should start to scroll with entries like this:

1307310795.647     32 192.168.1.106 TCP_MISS/302 768 GET http://us.archive.ubuntu.com/ubuntu/dists/natty-proposed/universe/i18n/Translation-en.xz - DIRECT/141.210.26.10 text/html
1307310795.683     34 192.168.1.106 TCP_MISS/302 752 GET http://us.archive.ubuntu.com/ubuntu/dists/natty/main/i18n/Translation-en_US.lzma - DIRECT/141.210.26.10 text/html

Which means the clients see the cache but are missing it, which is expected since it hasn't cached anything yet. Each subsequent run should show up as TCP_HIT. You can find the squid cache files themselves in /var/cache/squid-deb-proxy.
Using it

From then on all the machines on your network will check the cache before hitting the outside network to fetch packages. If there are new packages available then the first machine will download it from the net, after that subsequent requests for that package will come from the server to the clients.