Question

I have created new environment "staging". Locally it works. I run it this way:

RAILS_ENV=staging passenger start

On server I use Nginx + passenger. In virtual host settings I have written:

server {
        listen       443;
        server_name  test.myapp.com;
        rails_env staging;
        root /home/admin/myapp/current/public; # <-- be sure to point to 'public'
        passenger_enabled on;
        ssl on;
        ssl_certificate /home/admin/ssl/server.crt;
        ssl_certificate_key /home/admin/ssl/server.key;
}
server {
        listen 80;
        server_name  test.myapp.com;
       root /home/admin/myapp/current/public;  
        rewrite ^ https://$server_name$request_uri? permanent;
}

But app still runs in production. It loads production database, not staging. Reloading Nginx doesn't help. What is wrong?

Was it helpful?

Solution

i think you are missing the rails_env setting.

server {
  ...
  rails_env staging;
}

OTHER TIPS

Does the .bashrc or .zshrc for the user contain the RAILS_ENV setting? If so, it may be overriding the NGINX setting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top