【问题标题】:Rails app rendered white blank page! Unicorn + Nginx + minaRails 应用程序呈现白色空白页!独角兽 + Nginx + mina
【发布时间】:2015-06-28 21:43:16
【问题描述】:

我花了一整天的时间来解决这个问题,但我还没有得到它。 我在 digitaloceon 中创建了一个 droplet,我安装了 rvm 并使用 mina 部署了我的 rails 应用程序。我已经创建了交换区。

所以,我确定我的应用程序路径在 nginx 配置和 routes.rb 中是正确的。但是 rails 在我的域名和服务器 IP 上也呈现了一个空白页面。

我检查了 unicorn.stder.log 我看到了这些日志:

Instance method "open" is already defined in Object, use generic helper instead or set StateMachine::Machine.ignore_method_conflicts = true. 
I, [2015-04-21T14:35:55.148457 #18765]  INFO -- : listening on addr=/tmp/unicorn.sock fd=12
I, [2015-04-21T14:35:55.169044 #18765]  INFO -- : master process ready
I, [2015-04-21T14:35:55.186923 #18769]  INFO -- : worker=0 ready
I, [2015-04-21T14:35:55.195608 #18772]  INFO -- : worker=1 ready
E, [2015-04-21T14:35:58.821812 #18769] ERROR -- : app error: (<unknown>): mapping values are not allowed in this context at line 8 column 56 (Psych::SyntaxError)
E, [2015-04-21T14:35:58.821983 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse'
E, [2015-04-21T14:35:58.822057 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:370:in `parse_stream'
E, [2015-04-21T14:35:58.822106 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:318:in `parse'
E, [2015-04-21T14:35:58.822141 #18769] ERROR -- : /usr/local/rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/psych.rb:245:in `load'
E, [2015-04-21T14:35:58.822174 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:339:in `secrets'
E, [2015-04-21T14:35:58.822216 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:477:in `validate_secret_key_config!'
E, [2015-04-21T14:35:58.822251 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/application.rb:195:in `env_config'
E, [2015-04-21T14:35:58.822301 #18769] ERROR -- : /var/www/myapp/current/vendor/bundle/ruby/2.1.0/gems/railties-4.1.9/lib/rails/engine.rb:510:in `call'

这是我的 nginx sites-available/myapp.com

upstream app {
    # Path to Unicorn SOCK file, as defined previously
    server unix:/tmp/unicorn.sock fail_timeout=0;
}

server {


    listen 80;
    server_name .mydomain.com;

    # Application root, as defined previously
    root /var/www/myapp/current/public;

    try_files $uri/index.html $uri @app;

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app;
    }

    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 10;
    }

谁能告诉我,怎么了?请!

【问题讨论】:

  • 1) 您在浏览器中输入的域名是什么,导致您进入空白页面? 2) 你的 Rails 应用程序正在运行吗?如果是在哪个港口?
  • 它在默认端口 (22) 上工作。您可以在 mercandiamond.com 上查看。刷新时应用程序无法正常工作我在 unicorn.log 中收到以下错误

标签: ruby-on-rails nginx rvm unicorn mina


【解决方案1】:

看看这个修改后的 nginx 配置是否有效

upstream app {
  # Path to Unicorn SOCK file, as defined previously
  server unix:/tmp/unicorn.sock fail_timeout=0;
}

server {


  listen 80;
  server_name mercandiamond.com www.mercandiamond.com;

  # Application root, as defined previously
  root /var/www/myapp/current/public;

  location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://localhost:22/;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
}

如果没有,请确保

1) sites-enabled/myapp.com 匹配sites-available/myapp.com

2) 运行 nginx -s reload

希望这会有所帮助!

【讨论】:

  • 感谢您的回答,但 sites-enabled/myapp.com 和 sites-avilable/myapp 是一样的。我认为这个问题更难。
  • 你修改你的 nginx 配置了吗?无论如何,您最初列出的 server_name 和 proxy_pass 应该是固定的。
  • Chrome 浏览器中出现“未收到数据”而不是空白页。
  • 好吧,至少不再有空白页了 :-) 假设您没有更改 /etc/nginx/nginx.conf 上的 nginx 默认配置,请检查 /var/log/nginx/error 中的 nginx 错误日志.log 看看它给出了什么错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-09-27
  • 2022-11-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-17
  • 1970-01-01
相关资源
最近更新 更多