[英]setting up a virtual host with unicorn, nginx and capistrano in rails
我已经能够使用nginx,unicorn和capistrano将我的rials应用程序部署到vps系统中,没有任何错误。 现在,我想在同一个vps服务器内使用相同的nginx配置(下面的两个脚本)部署另一个rails应用程序,并在运行cap deploy之后:setup和cap deploy:cold它设置正确并且rails应用程序被发送到服务器。 我得到的问题是这个。 当我键入service nginx restart
我得到以下错误
nginx: [emerg] duplicate upstream "unicorn" in /etc/nginx/sites-enabled/cf:1
nginx: configuration file /etc/nginx/nginx.conf test failed
我正在运行的第一个应用程序的nginx脚本是
upstream unicorn {
server unix:/tmp/unicorn.cf.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name cfmagazineonline.com;
root /home/deployer/apps/cf/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
我的nginx配置为第二个rails应用程序无法运行,但改为第一个rails应用程序的错误并使其崩溃是
upstream unicorn {
server unix:/tmp/unicorn.gutrees.sock fail_timeout=0;
}
server {
listen 80 default deferred;
server_name gutrees.com;
root /home/deployer/apps/gutrees/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
任何想法我如何解决这个问题并正确设置虚拟主机。 谢谢
以不同方式命名您的第二个应用上游(上游名称必须是唯一的)。 因此,而不是使用unicorn
即名称@my_shiny_app_server
。 然后使用此名称proxy_pass指令http://my_shiny_app_server
。 将my_shiny
字符串替换为应用程序的名称,例如gutrees
, cf
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.