502 Bad gateway / rails 4 / nginx / passenger 4.0.49 /

I can’t find my mistake ... and how to fix it.

he seems to have 2 errors

I also feel that my server is not starting, I don’t know where to look for verification, but the restart.txt file in the tmp file is not cleared (even after chmod 777 tmp) Therefore, I think my server does not restart after my change.

I tried to create an index.html file in a public folder. And it works. index.html looks good

cat / var / log / nginx / error.log

App 10349 stderr: [ 2014-08-23 13:25:55.4598 10419/0x00000001c8b3c8(Worker 1) utils.rb:72 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 10419, thread 0x00000001c8b3c8(Worker 1)): App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/application.rb:452:in `validate_secret_key_config!' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/application.rb:195:in `env_config' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/engine.rb:510:in `call' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/railties-4.1.5/lib/rails/application.rb:144:in `call' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.49/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.49/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.49/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop' App 10349 stderr: from /home/server/.rvm/gems/ruby-2.1.2/gems/passenger-4.0.49/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads' 2014/08/23 13:25:55 [error] 10328#0: *12 upstream prematurely closed connection while reading response header from upstream, client: 83.205.180.121, server: , request: "GET / HTTP/1.1", upstream: "passenger:/tmp/passenger.1.0.10303/generation-0/request:", host: "195.154.114.102" server@sd-22885 :~/blog/config$ 

cat secrets.yml

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

my env =>

 SECRET_KEY_BASE=39d95ff31bba12f1ea6bf0f2e332fc7b4797679b04ce9d45deb155fdc090a57960ee3fae82383fa18015c9444f5828769ae896c5dbe32e0916da23b79304f7fc 

sudo vim / etc / nginx / sites-enabled / default

 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; # server_name mydomain.com; passenger_enabled on; rails_env production; root /home/server/blog/public; # client_max_body_size 32M; # client_body_buffer_size 512k; # proxy_connect_timeout 90; # proxy_send_timeout 90; # proxy_read_timeout 1200; # proxy_buffers 32 4k; } 

thank you

+6
source share
2 answers

Did you try to install

 passenger_set_cgi_param SECRET_KEY_BASE "39d95ff31bba12f1ea6bf0f2e332fc7b4797679b04ce9d45deb155fdc090a57960ee3fae82383fa18015c9444f5828769ae896c5dbe32e0916da23b79304f7fc"; 

in your site settings?

+8
source

Try deferring the secrets.yml file correctly:

 production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 

The error says that it cannot find this variable for production env.

0
source

Source: https://habr.com/ru/post/974246/


All Articles