QA@IT

How to use vagrant on windows under a proxy environment?

5822 PV

Windows version:7

I have installed vagrant-proxyconf

vagrant plugin install vagrant-proxyconf

Then run

vagrant init precise32 http://files.vagrantup.com/precise32.box

Setting for Vagrantfile under the folder,add config.proxy.http , config.proxy.https and config.proxy.no_proxy

Vagrant.configure("2") do |config|
  config.proxy.http     = "http://a-proxy-url:1234"
  config.proxy.https    = "http://a-proxy-url:1234"
  config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
  # ... other stuff
end

When I run

vagrant up

It showed me

C:\Vagrant>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Box 'precise32' was not found. Fetching box from specified URL for
the provider 'virtualbox'. Note that if the URL does not have
a box for this provider, you should interrupt Vagrant now and add
the box yourself. Otherwise Vagrant will attempt to download the
full box prior to discovering this error.
Downloading box from URL: http://files.vagrantup.com/precise32.box
Download failed. Will try another box URL if there is one.-)
An error occurred while downloading the remote file. The error
message, if any, is reproduced below. Please fix this error and try
again.

The requested URL returned error: 401 Unauthorized

How to set vagrant proxy rightly?

回答

Perhaps, you need set username and password to config.

Vagrant.configure("2") do |config|
  config.proxy.http     = "http://<user_for_proxy>:<password>@a-proxy-url:1234"
  config.proxy.https    = "http://<user_for_proxy>:<password>@a-proxy-url:1234"
  config.proxy.no_proxy = "localhost,127.0.0.1,.example.com"
  # ... other stuff
end

Edited

https://github.com/tmatilai/vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies

vagrant-proxyconf is NOT for vagrant, for guest os.

If you want to configure the proxy to download precise32.box, you probably should do following:

> set http_proxy=http://a-proxy-url:1234
> set https_proxy=http://a-proxy-url:1234
> vagrant up

( or add to your system environment variables. )

note: you don't need add username and password to your Vagrantfile, sorry.

編集 履歴 (2)
  • Maybe,but I don't know the username and the password. -
ウォッチ

この質問への回答やコメントをメールでお知らせします。