简体   繁体   中英

Multi-staging environment for Rails with Nginx

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?

i think you are missing the rails_env setting.

server {
  ...
  rails_env staging;
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM