502 Bad Gateway / rails 4 / nginx / passenger 4.0.49 /
Asked Answered
S

2

8

I can not find my error...and how to fix it.

it seem to have 2 errors

I also feel that my server does not start, I do not know where to look for check but The file restart.txt in tmp does not clear, (even after chmod 777 tmp) So I think my server does not restart after my change.

I tried to create an index.html file in the public folder. And it work. index.html appears well

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;
}

thanks you

Saloma answered 23/8, 2014 at 12:19 Comment(1)
Is your secrets.yml file indented properly?Sculpt
C
9

Did you try setting

passenger_set_cgi_param SECRET_KEY_BASE "39d95ff31bba12f1ea6bf0f2e332fc7b4797679b04ce9d45deb155fdc090a57960ee3fae82383fa18015c9444f5828769ae896c5dbe32e0916da23b79304f7fc";

in your site configuration?

Clavicorn answered 23/8, 2014 at 13:30 Comment(2)
S
0

Try indenting your secrets.yml file correctly:

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

The error says it's not able to find this variable for the production env.

Sculpt answered 23/8, 2014 at 12:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.