【发布时间】:2014-01-21 06:35:25
【问题描述】:
使用ruby app.rb 和foreman start 启动我的Sinatra 应用程序后,我无法使用localhost 和主机上的相应端口访问我的应用程序。我还可以在来宾机器的外壳中 curl 到应用程序,而在主机上 curl 请求失败。据我所知,来宾机器上不应该有防火墙,因为我使用的是 Vagrant Ubuntu 映像。
我的 Vagrantfile 如下:
Vagrant.configure('2') do |config|
config.vm.box = 'precise32'
config.vm.box_url = 'http://files.vagrantup.com/precise32.box'
config.vm.network :forwarded_port, guest: 4567, host: 4567
end
【问题讨论】:
-
这可能是因为默认情况下在开发模式下 Sinatra only listens to localhost,而不是 0.0.0.0(我不知道 Vagrant 如何处理转发以及客人如何看到任何要求)。在您的应用中使用
set :bind, '0.0.0.0'是否使其可用?
标签: ruby http ubuntu sinatra vagrant