Ubuntu 如何通过浏览器ping vagrant ip和运行在vagrant上的项目
我已经在windows8上安装了vagrant ubuntu/precise32。我用它来运行一个rails项目 当我开始安装在vagrant中的rails项目时。它会提示我在浏览器中pingUbuntu 如何通过浏览器ping vagrant ip和运行在vagrant上的项目,ubuntu,networking,windows-8,virtualbox,vagrant,Ubuntu,Networking,Windows 8,Virtualbox,Vagrant,我已经在windows8上安装了vagrant ubuntu/precise32。我用它来运行一个rails项目 当我开始安装在vagrant中的rails项目时。它会提示我在浏览器中pinglocalhost或0.0.0。正在处理“流浪者”框,如何在浏览器上ping此项 -deploy$ rails s => Booting Thin => Rails 4.0.3 application starting in development on http://0.0.0.0:3000
localhost
或0.0.0
。正在处理“流浪者”框,如何在浏览器上ping此项
-deploy$ rails s
=> Booting Thin
=> Rails 4.0.3 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server Thin web server (v1.6.1 codename Death Proof) Maximum
connections set to 1024 Listening on 0.0.0.0:3000, CTRL+C to stop
因此,我无法使用流浪汉。请务必让我知道如何使用浏览器查看此项目。这取决于您使用的提供商。在最简单的情况下,当您使用virtualbox或类似软件时,您可以在vagrant中设置端口转发(请参阅:)。为了转发端口,您必须在vagrant配置块中附加以下内容:
config.vm.network "forwarded_port", guest: 3000, host: 3000
您必须运行vagrant reload
,以便由vagrant设置端口转发。此外,您始终可以通过virtualbox GUI手动转发已经运行的VM上的端口(请参见示例)
在更复杂的情况下,您使用云提供商,如EC2、cloudstack等,vagrant会这样告诉您:
Warning! The Cloudstack provider doesn't support any of the Vagrant
high-level network configurations (`config.vm.network`). They
will be silently ignored.
ssh -N -L3000:localhost:3000 -i ~/.vagrant.d/insecure_private_key vagrant@machineip
在vagrant启动机器后,您可以通过运行vagrant ssh config
找到机器的IP,并使用ssh隧道转发端口,如下所示:
Warning! The Cloudstack provider doesn't support any of the Vagrant
high-level network configurations (`config.vm.network`). They
will be silently ignored.
ssh -N -L3000:localhost:3000 -i ~/.vagrant.d/insecure_private_key vagrant@machineip