Caching HTTP proxy around vagrant boxes

992 views
Skip to first unread message

John D. Hume

unread,
Sep 25, 2011, 6:23:07 PM9/25/11
to vagra...@googlegroups.com
Is anyone using a local caching HTTP proxy on their host machine to
speed up and reduce bandwidth demands of frequent vagrant rebuilds? If
so what do you use, and how do you configure it? I use vagrant to test
deployment scripts, so I'm constantly rebuilding from scratch and
downloading basically the same apt packages, gems, and source
tarballs.

I don't understand VirtualBox networking at all well enough to know
whether the guest machine will pick up something configured as
HTTP_PROXY on the host or if it's more complex than that.

Thanks.
-hume.
--
http://elhumidor.blogspot.com/

Chris

unread,
Sep 26, 2011, 11:50:24 AM9/26/11
to Vagrant
I have actually heard, have never tried..., a lot of success with
squid proxy for tasks like this (e.g. http://reluctanthacker.rollett.org/node/114).

Personally, (given I mainly use Ubuntu virtualbox images) I expose the
apt-cache via a shared folder onto the parent system. Then the apt-
cache persists beyond the one virtual box spin-up ... this seems to
help, but obviously doesn't cover all over the wire requests.

Ben Butler-Cole

unread,
Sep 27, 2011, 10:16:45 AM9/27/11
to vagra...@googlegroups.com
That's very interesting, Chris. I've been using a cache like the one you describe for stuff that I download by explicitly, but haven't tried linking it to the apt cache. How do you set that up -- by symlinking /var/cache/apt to a vagrant share directory?

-Ben

Chris

unread,
Sep 28, 2011, 8:26:21 AM9/28/11
to Vagrant
Basically yes, I have found that copying the apt-cache directory "/var/
cache/apt" *and then* linking out to the host system the best way to
do this (apt errors if the directory is empty; and, you only have to
do this once... from my experience it works across multiple
instances).

Vagrantfile:
<code>config.vm.share_folder("v-apt", "/var/cache/apt", "~/temp/
vagrant_aptcache/apt", :nfs => true)</code>

John D. Hume

unread,
Sep 28, 2011, 12:02:44 PM9/28/11
to vagra...@googlegroups.com

I'd also only heard good things about Squid for this. Last night I set it up as a transparent proxy on my host machine (with some iptables rules to route all http but squid's through squid) and that got all my guest machine requests running through squid.

I was still seeing mostly cache misses on the second run of my provisioning, so my guess is that next I need to configure cache size and/or expiration policy (or something like that).

Once I get things working well I'll update this thread with details.

-- typed with my thumbs

Patrick Connolly

unread,
Feb 1, 2012, 2:32:24 AM2/1/12
to vagra...@googlegroups.com
What about sharing the squid cache between the host and VM? Like check which the cache dir exists on the host, and if so, share it with the VM at /var/spool/squid3 with some simple Vagrantfile logic.

I'm thinking the benefit would be for environments that are meant to be shared as public tools. That way, even if the other user didn't use squid on the host, they'd still have a persistent cache, at least until destroying the VM. And having a squid cache ipersistent in the VM between destroys would be as simple as creating the cache dir on the host. So on mac, the user would just need to create ~/Library/Caches/squid, and now the VM's squid cache will stick around, even though it's not used by the host (since no squid installed there).

Would this be a bad approach?
Reply all
Reply to author
Forward
0 new messages