应用程序收到的反应不完整 - 乘客和NGINX

时间:2016-10-09 04:36:13

标签: ruby-on-rails azure nginx passenger

我已成功使用Passenger + Nginx安装了rails,但是通过网络浏览器遇到了不完整的响应错误:

http://tenklakes.northcentralus.cloudapp.azure.com/

我已尝试rake secrets在我的secret_key_base文件中为production生成新secrets.yml但没有运气。

Secrets.yml:

development: secret_key_base:c70c590cfe799087c47528016ab49a1a8e57fe2eb851639e27e2ea66f92f241a0400b3d4247e3d61a6c82818dd3988825deeb66e783ba90cfccfbc0c500d6dbd

test: secret_key_base: 08b1ebf5defee2eb1ad196e9780ae118f256c9f40f40f76674451dac4dfb1c42b75f04d22ee264644711de4e547ac8f58031e88f09c5c7223834b99230fb205c

# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

当我跑curl http:0.0.0.0:3000时,我从乘客那里收到以下信息:

Started GET "/" for 127.0.0.1 at 2016-10-09 04:52:43 +0000 Processing by Rails::WelcomeController#index as */* Parameters: {"internal"=>true} Rendering /home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/templates/rails/welcome/index.html.erb Rendered /home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/templates/rails/welcome/index.html.erb (2.5ms) Completed 200 OK in 10ms (Views: 6.2ms | ActiveRecord: 0.0ms)

NGINX error.log:

  

[2016-10-09 04:49:44.8271 45647 / 7fe3b30d4700 age / Cor / Con / InternalUtils.cpp:112]:[客户1-3]发送502响应:应用程序未发送完整响应   App 45674 stderr:[2016-10-09 04:49:56.0108 45754 / 0x0000000092d678(Worker 1)utils.rb:87]:*** Rack应用程序对象中的异常RuntimeError(缺少secret_key_base的'生产'环境,在config/secrets.yml中设置此值(进程45754,线程0x0000000092d678(工作者1)):   App 45674 stderr:来自/home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:513:in validate_secret_key_config!' App 45674 stderr: from /home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:246:in env_config'   App 45674 stderr:来自/home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:693:in build_request' App 45674 stderr: from /home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/application.rb:521:in build_request'   App 45674 stderr:来自/home/garrett/.rvm/gems/ruby-2.3.0/gems/railties-5.0.0.1/lib/rails/engine.rb:521:in call' App 45674 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in process_request'   App 45674 stderr:来自/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:152:in accept_and_process_next_request' App 45674 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:113:in main_loop'   App 45674 stderr:来自/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:416:in block (3 levels) in start_threads' App 45674 stderr: from /usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in块中的create_thread_and_abort_on_exception'

我没有想法让这个工作 - 我还有什么我应该检查的吗?

编辑:这是我在运行'grep -r ENV *'

时得到的结果
garrett@10klakes:~/lakemag$ grep -r ENV *
bin/bundle:ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
config/database.yml:  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
config/database.yml:#     url: <%= ENV['DATABASE_URL'] %>
config/database.yml:  password: <%= ENV['LAKEMAG_DATABASE_PASSWORD'] %>
config/puma.rb:threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
config/puma.rb:port        ENV.fetch("PORT") { 3000 }
config/puma.rb:environment ENV.fetch("RAILS_ENV") { "development" }
config/puma.rb:# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
config/environments/production.rb:  # config.secret_key_base =   ENV["SECRET_KEY_BASE"]
config/environments/production.rb:  config.secret_key_base = ENV["SECRET_KEY_BASE"]
config/environments/production.rb:  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
config/environments/production.rb:  if ENV["RAILS_LOG_TO_STDOUT"].present?
config/boot.rb:ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
config/secrets.yml:  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

test / test_helper.rb:ENV ['RAILS_ENV'] || ='test'

2 个答案:

答案 0 :(得分:0)

对于foreach (Char c in inputString) { if (Char.IsSurrogate(c)) throw new ArgumentOutOfRangeException(); if (c > '\u007f') throw new ArgumentOutOfRangeException(); // add your logic to increment c and save or output it } 模式,您必须设置在任何ruby或配置文件中命名的所有production(环境)变量。例如,在ENV内,Rails需要一个环境变量secrets.yml。您没有设置此变量,现在Rails无法以SECRET_KEY_BASE模式启动。

您正在使用asure作为托管服务提供商。所以你可以关注this post 为azure设置环境变量。简而言之:

  

在&#34;应用设置&#34;中添加应用设置节

您可以使用production生成新密钥并将其用于环境变量。

还有一个提示。 rake secret因其原因而得名。您不应该从此文件发布秘密。

答案 1 :(得分:0)

经过大量研究后,问题出现在hba_config文件中。 md5权限需要设置为&#34; trust&#34;代替。

我不确定这个解决方案是否是完整的&#34;修复,但它在我的情况下工作。