diff --git a/README.dev.md b/README.dev.md index 9ae15ad1de..11360d0a6f 100644 --- a/README.dev.md +++ b/README.dev.md @@ -90,6 +90,29 @@ environment][using-dev]. [using-dev]: #using-the-development-environment +## Specifying a proxy + +If you need to use a proxy server to access the Internet, you will +need to specify the proxy settings before running `Vagrant up`. +First, install the Vagrant plugin `vagrant-proxyconf`: + +``` +vagrant plugin install vagrant-proxyconf. +``` + +Then create `~/.zulip-vagrant-config` and add the following lines to +it (with the appropriate values in it for your proxy): + +``` +HTTP_PROXY http://proxy_host:port +HTTPS_PROXY http://proxy_host:port +NO_PROXY localhost,127.0.0.1,.example.com + +``` + +Now run `vagrant up` in your terminal to install the development +server. If you ran `vagrant up` before and failed, you'll need to run +`vagrant destroy` first to clean up the failed installation. Using provision.py without Vagrant ---------------------------------- diff --git a/Vagrantfile b/Vagrantfile index 34e0b9dc99..faf1b5dc71 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,6 +18,34 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder ".", "/srv/zulip" + proxy_config_file = ENV['HOME'] + "/.zulip-vagrant-config" + if File.file?(proxy_config_file) + http_proxy = https_proxy = no_proxy = "" + + IO.foreach(proxy_config_file) do |line| + line.chomp! + key, value = line.split(nil, 2) + case key + when /^([#;]|$)/; # ignore comments + when "HTTP_PROXY"; http_proxy = value + when "HTTPS_PROXY"; https_proxy = value + when "NO_PROXY"; no_proxy = value + end + end + + if Vagrant.has_plugin?("vagrant-proxyconf") + if http_proxy != "" + config.proxy.http = http_proxy + end + if https_proxy != "" + config.proxy.https = https_proxy + end + if https_proxy != "" + config.proxy.no_proxy = no_proxy + end + end + end + # Specify LXC provider before VirtualBox provider so it's preferred. config.vm.provider "lxc" do |lxc| if command? "lxc-ls"