3

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?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Vasilina
  • 335
  • 3
  • 11

2 Answers2

4

i think you are missing the rails_env setting.

server {
  ...
  rails_env staging;
}
phoet
  • 18,688
  • 4
  • 46
  • 74
0

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

scarver2
  • 7,887
  • 2
  • 53
  • 61