Created
March 31, 2015 16:38
-
-
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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not exactly bug-free or ironclad.