【问题标题】:localhost:8080 not running in unicornlocalhost:8080 未在独角兽中运行
【发布时间】:2013-11-02 04:04:53
【问题描述】:

在我的虚拟机 ubuntu32 中,我安装了 nginx。

http://192.168.11.8/ 

显示欢迎使用 nginx!页。

我在 vagrant 目录中添加了 rails 应用程序。我在 railapp/config/unicorn.rb 中安装了 unicorn gem 和以下内容

working_directory File.expand_path("../..", __FILE__)

现在当我运行时

vagrant@precise32:/vagrant$ bundle exec unicorn -c config/unicorn.rb

,它在我的终端中显示以下内容。

vagrant@precise32:/vagrant$ bundle exec unicorn -c config/unicorn.rb
I, [2013-11-02T03:53:34.983828 #19364]  INFO -- : listening on addr=0.0.0.0:8080 fd=9
I, [2013-11-02T03:53:34.984324 #19364]  INFO -- : worker=0 spawning...
I, [2013-11-02T03:53:34.985178 #19364]  INFO -- : master process ready
I, [2013-11-02T03:53:34.986044 #19479]  INFO -- : worker=0 spawned pid=19479
I, [2013-11-02T03:53:34.986595 #19479]  INFO -- : Refreshing Gem list
I, [2013-11-02T03:53:37.303696 #19479]  INFO -- : worker=0 ready

但是当我访问 localhost:8080 时,它显示“糟糕!Google Chrome 无法连接到 localhost:8080”。

当我运行bundle exec rails s 时,railsapp 运行在

http://192.168.11.8:3000/

我做错了什么?

【问题讨论】:

  • 您是在 VM 上还是在主机上运行 Chrome? localhost 只能在虚拟机内工作——否则你需要使用虚拟机的 IP。
  • 你是否在 Vagrantfile 上将 8080 配置为转发?

标签: ruby-on-rails ruby nginx vagrant unicorn


【解决方案1】:

您需要设置 nginx 以侦听端口 8080 并将该端口上的请求转发到您的应用程序。查看example nginx config for unicorn 了解如何设置。

希望这会有所帮助!

【讨论】:

    猜你喜欢
    • 2017-10-06
    • 1970-01-01
    • 2013-03-05
    • 1970-01-01
    • 2019-08-07
    • 2014-01-15
    • 2012-01-05
    • 2016-10-05
    • 2014-10-24
    相关资源
    最近更新 更多