我在一个专用networkingIP的stream浪盒子上安装了CentOS 6。 我可以使用IP ssh到盒子,所以这是工作。 但是,在curl'ing时,我在端口80上收到拒绝连接。 里面有一个非常基本的nginx提供默认的欢迎页面。 从盒子内部curl它的作品。
Vagrant.configure("2") do |config| config.vm.box = "Centos-6.3-minimal" config.vm.box_url = "https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box" config.vm.network :private_network, ip: "192.168.33.44" config.vm.hostname = "local.example.com" config.vm.provider :virtualbox do |vb| vb.customize ["modifyvm", :id, "--memory", "2048"] end end
以下是我尝试过的一些事情:
localhost:8080
curllocalhost:8080
只是挂在那里。 0.0.0.0
上侦听的服务器上打开python -m SimpleHTTPServer
。 仍然得到连接拒绝。 这些东西是已知的工作:
我已经安装了Guest Additions,但是它们的版本在guest和host上是不同的。 这可能是问题所在。 但是为什么SSH工作,而不是端口80? 这是我做vagrant reload
时的输出: https : //gist.github.com/magnars/496e553f07ad5c770c54
虽然这不起作用:
config.vm.network :forwarded_port, guest: 80, host: 8080
这样做:
ssh -f [email protected] -L 8080:127.0.0.1:80 -N
有任何想法吗?
虽然有许多事情可能是错误的,但第一个要检查的是客户端内的防火墙:它可以像对端口22但不是端口80那样简单。
通过禁用来宾主机中的防火墙解决了同样的问题
sudo service iptables stop sudo service ip6tables stop
你可以使用iptables --list
来检查
[vagrant@c6401 ~]$ sudo iptables --list Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination