Skip to content

Instantly share code, notes, and snippets.

@randomcamel
Created March 31, 2015 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randomcamel/a1ed4118ac61ed0f942e to your computer and use it in GitHub Desktop.
Save randomcamel/a1ed4118ac61ed0f942e to your computer and use it in GitHub Desktop.
Configure Vagrant to use Polipo on the OS X host as an HTTP(S) caching proxy
# this saves us from both hard-coding an IP, and using a non-bridged IP for the VM.
iface = `ifconfig -l`.match(/(vbox|vmnet.*?) /)[1]
local_ip = `ifconfig #{iface}`.match(/inet (.*?) /)[1]
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
if `lsof -i |egrep -e '^polipo.*TCP \\*:8123.*LISTEN'`.to_s.empty?
$stderr.puts "lsof doesn't see polipo listening on *:8123; running without a proxy."
elsif local_ip
config.proxy.http = "http://#{local_ip}:8123/"
config.proxy.https = "http://#{local_ip}:8123/"
config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
end
end
end
@randomcamel
Copy link
Author

Not exactly bug-free or ironclad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment