我有以下设置:
通过将环境变量设置http_proxy
为我们的代理,我可以为流浪者用户配置VBox图像以访问Internet 。但是,当我尝试在Shell Provisioning中设置代理时,出现了问题。以下是定义代理的脚本部分,以及首次访问互联网的部分:
# Base setup proxy and DISPLAY
set HTTP_PROXY=http://proxy.name.com:8080
echo "Add proxy to necessary parts"
echo 'export http_proxy=http://proxy.name.com:8080' >> ~vagrant/.bash_profile
echo 'export DISPLAY=192.168.137.1:0.0' >> ~vagrant/.bash_profile
echo 'export http_proxy=http://proxy.name.com:8080' >> /root/.bash_profile
export http_proxy=$HTTP_PROXY
# Install Git
echo "Install Git"
apt-get update
apt-get install -y git
...
但是,我得到以下输出:
Add proxy to necessary parts
Install Git
Err http://security.ubuntu.com trusty-security InRelease
Err http://archive.ubuntu.com trusty InRelease
Err http://archive.ubuntu.com trusty-updates InRelease
Err http://security.ubuntu.com trusty-security Release.gpg
Could not resolve 'security.ubuntu.com'
Err http://archive.ubuntu.com trusty Release.gpg
Could not resolve 'archive.ubuntu.com'
Err http://archive.ubuntu.com trusty-updates Release.gpg
Could not resolve 'archive.ubuntu.com'
Reading package lists...
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
...
如何设置一个Unix脚本中的代理,并立即使用它,这样apt-get
,git clone
...可以使用?
有一个插件!
vagrant plugin install vagrant-proxyconf
对其进行配置(对于所有Vagrant VM,在$ HOME / .vagrant.d / Vagrantfile中):
Vagrant.configure("2") do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://10.206.246.20:8080"
config.proxy.https = "http://10.206.246.20:8080"
config.proxy.no_proxy = "localhost,127.0.0.1"
end
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句