Reputation: 796
I defined environment variables in nginx.conf like below -
server {
listen 80;
server_name XX.XX.XX.XX; //Masked for this question
location ~ ^/clients/abc(/.*|$) {
alias /home/abc/Project/public$1;
passenger_base_uri /clients/abc;
passenger_app_root /home/abc/Project;
passenger_document_root /home/abc/Project/public;
passenger_enabled on;
passenger_env_var AWS_U disha;
}
}
I restarted nginx but when I open rails c
and type ENV['AWS_U']
, it returns nil
.
What possibly could I be doing wrong?
Upvotes: 2
Views: 537
Reputation: 5138
Environment variables are only set when the application gets loaded by Passenger. They are not set when the application starts by rails c
command.
If you want to know the value of an environment varialbe on the running application loaded by Passenger, you can make a temporal action for debugging:
class DebugController < ApplicationController
def foobar
render plain: "FOOBAR = '#{ENV['FOOBAR']}'"
end
end
Rails.application.routes.draw do
get "/debug/foobar" => "debug#foobar"
end
Upvotes: 1
Reputation: 81
U need to move passenger_env_var
directive to server
section.
server {
...
passenger_env_var VAR value;
}
Upvotes: 2