我在公司 NTLM 代理后面的 Windows 机器上,我需要vagrant up
从给定的 VM 上获取Vagrantfile
。
我读过一些关于这个话题的内容:
- http://runefs.com/2014/11/28/setting-up-vagrant-behind-a-corporate-proxy/
- VirtualBox:如何设置网络以便主机和客户机都可以访问互联网并相互通信
我目前的情况:
我的 Windows 计算机上的 CNTLM 正在收听192.168.33.1:5865
。以下是cntlm -v -f
section: global, Listen = '5865'
section: global, Listen = '192.168.33.1:5865'
出口HTTP_PROXY
和HTTPS_PROXY
:
set HTTP_PROXY=http://192.168.33.1:5865
set HTTPS_PROXY=http://192.168.33.1:5865
安装vagrant-proxyconf
插件
创建了.vagrant.d\Vagrantfile
:
Vagrant.configure("2") do |config|
# configuration based on http://digitaldrummerj.me/vagrant-behind-proxy-server/
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://192.168.33.1:5865/"
config.proxy.https = "http://192.168.33.1:5865/"
config.proxy.no_proxy = "localhost,127.0.0.1,10.43.125.137,10.43.125.137,10.43.124.177"
end
end
设置 Windows 防火墙规则以允许所有程序和配置文件在任意端口上运行从192.168.33.10
到 的所有内容。192.168.33.1
我仍然得到:
==> default: Cannot add PPA: 'ppa:webupd8team/java'.
==> default: Please check that the PPA name or format is correct.
==> default: Err http://security.ubuntu.com trusty-security InRelease
==> default:
==> default: Err http://security.ubuntu.com trusty-security Release.gpg
==> default: Unable to connect to 192.168.33.1:5865:
==> default: Err http://archive.ubuntu.com trusty InRelease
==> default:
==> default: Err http://archive.ubuntu.com trusty-updates InRelease
==> default:
==> default: Err http://archive.ubuntu.com trusty-backports InRelease
==> default:
==> default: Err http://archive.ubuntu.com trusty Release.gpg
==> default: Unable to connect to 192.168.33.1:5865:
==> default: Err http://archive.ubuntu.com trusty-updates Release.gpg
==> default: Unable to connect to 192.168.33.1:5865:
==> default: Err http://archive.ubuntu.com trusty-backports Release.gpg
==> default: Unable to connect to 192.168.33.1:5865:
==> default: Reading package lists...
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/InRelease
==> default:
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/InRelease
==> default:
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/InRelease
==> default:
==> default: W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/InRelease
==> default:
==> default: W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/trusty-security/Release.gpg Unable to connect to 192.168.33.1:5865:
==> default:
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release.gpg Unable to connect to 192.168.33.1:5865:
==> default:
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-updates/Release.gpg Unable to connect to 192.168.33.1:5865:
==> default:
==> default: W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty-backports/Release.gpg Unable to connect to 192.168.33.1:5865:
==> default:
==> default: W: Some index files failed to download. They have been ignored, or old ones used instead.
注意所有这些Unable to connect to 192.168.33.1:5865
。
为什么我的客户机无法连接到主机上的代理?我该如何诊断?
我非常确定 CNTLM 代理可以正常工作,Vagrant 本身会访问它几次以检查该框是否仍然有效。但稍后执行的配置脚本却无法访问。
我已经尝试了好几个小时,越来越绝望了。有人有主意吗?
答案1
我也尝试了你提供的链接,但没有成功,然后我遇到了:使用 vagrant 和 cntlm 代理我们都犯的错误是使用仅限主机网络(例如 192.168.33.*)我们想要访问互联网,所以我们应该使用互联网连接网络(Vagrant NAT 适配器)。
安装 vagrant-proxyconf 插件并将代理变量设置为 10.0.2.2:5865。