有以下nginx主机配置:
server {
listen 80;
server_name production2.somedomain.co;
root /home/engine/domains/production2_web_app;
client_max_body_size 2m;
rails_env production2;
location /api {
passenger_enabled on;
rails_env production;
root /home/engine/domains/production2_app/current/public;
}
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
try_files $uri /index.html;
}
}
正如您所看到的,我的应用程序'rails_env'是'production2',但是当我尝试打开我的production2 URL时,我看到数据库'production'中的数据。此外,在同一台服务器上还有以下nginx配置:
server {
listen 80;
server_name production.somedomain.co;
root /home/engine/domains/production_web_app;
client_max_body_size 2m;
rails_env production;
location /api {
passenger_enabled on;
rails_env production;
root /home/engine/domains/production_app/current/public;
}
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
try_files $uri /index.html;
}
}
'生产'应用程序运行良好,我看到'生产'数据库数据。有什么麻烦?如何设置'production2'环境?
答案 0 :(得分:0)
在production2配置中,您需要将rails_env生产更改为rails_env production2。
server {
listen 80;
server_name production2.somedomain.co;
root /home/engine/domains/production2_web_app;
client_max_body_size 2m;
location /api {
passenger_enabled on;
rails_env production2;
root /home/engine/domains/production2_app/current/public;
}
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
try_files $uri /index.html;
}
}