I used this railscast as a basis
# nginx_unicorn.erb
upstream unicorn-<%= application %> {
server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0;
}
server {
listen <%= subdomain ? subdomain : application %>.example.com:443 ssl;
server_name <%= subdomain ? subdomain : application %>.example.com;
root <%= current_path %>/public;
ssl on;
ssl_certificate /opt/nginx/ssl/example.com.pem;
ssl_certificate_key /opt/nginx/ssl/example.com.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;
ssl_session_cache shared:SSL:10m;
try_files $uri/index.html $uri @unicorn;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_pass http://unicorn-<%= application %>;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
我在deploy.rb
中将变量设置为子域# deploy.rb
...
role :web, "avps.example.com", "bvps.example.com", "cvps.example.com"
role :app, "avps.example.com", "bvps.example.com", "cvps.example.com"
role :db, "avps.example.com", "bvps.example.com", "cvps.example.com", :primary => true
set :subdomain, "atsp"
...
当我只部署到一台服务器时,这很有效,但我希望能够将它从它部署的当前服务器上取下来,所以如果它是avps.example.com,它会:
set :subdomain, "atsp"
或者如果是bvps.example.com,它会:
set :subdomain, "btsp"
有没有一种简单的方法可以实现这一目标?
答案 0 :(得分:0)
我认为您正在寻找的是Capistrano多阶段部署。您可以找到维基页面here。你所要做的就是移动
set :subdomain, "atsp"
使用服务器信息进入文件(即config / deploy / atsp.rb),然后使用
部署到该服务器cap atsp deploy
希望这有帮助。