Reputation: 476
I have ubuntu server, Rails 5.0 and apache web server Also I have many sites on it
When I add new site, I have an error "Incomplete response received from application"
When I check apache log I see message:
App 14561 stderr: [ 2017-01-17 21:01:16.5804 14591/0x0000000064e100(Worker 1) utils.rb:85 ]: *** Exception RuntimeError in Rack application object (Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`) (process 14591, thread 0x0000000064e100(Worker 1)):
My config/secrets.yml contains default value:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Also I have just setted env variable SECRET_KEY_BASE via writting in a file /etc/profile
I see than via command echo $SECRET_KEY_BASE
How to fix error Incomplete response received from application
Upvotes: 1
Views: 1500
Reputation: 2293
sudo a2enmod env
rake secret
... outputs a big long string ...
somewhere in /etc/apache2/sites-available/*.conf
<VirtualHost ...>
SetEnv SECRET_KEY_BASE "thebiglongstringgeneratedbyrakesecret"
</VirtualHost>
apache2ctl -t
Syntax OK
apache2ctl restart
curl https://my-server-url -I # or http
Leave a comment if that does do the trick.
Upvotes: 0
Reputation: 20390
First, note that /etc/profile
is only sourced when invoking an interactive login shell, so any variables set in this file wouldn't ever get run by a web-server daemon on startup, which is why it didn't work as expected in your attempt.
Since you're using Apache + Phusion Passenger, you can set application-specific environment variables within your Apache configuration files using the SetEnv
option of mod_env
.
Otherwise, you could set your environment variables from your application code by reading configuration on your application server's filesystem. You could use a gem like dotenv
to automate this pattern.
See Phusion Passenger's documentation About Environment Variables: Passenger-Served Apps for a documentation reference.
Upvotes: 2
Reputation: 2330
Depending on how you are starting the server the ENV variables may not be visible.
Have you tried:
SECRET_KEY_BASE='foo' rails s
Some discussion on environment variables with Rails servers is discussed at How to start Rails server with environment variables set?
Upvotes: 1
Reputation: 3018
Try restarting your server, it might need to be restarted to pick up new changes in your config
files.
Your config/secrets.yml file should also have:
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Upvotes: 2