1

私はこのレールキャストをベースとして使用しました

# 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 で subdomain に変数を設定しました

# 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"
...

これは、1 つのサーバーにのみデプロイする場合にうまく機能しますが、デプロイ先の現在のサーバーに基づいてこれをベースにしたいので、avps.example.com の場合は次のようになります。

set :subdomain, "atsp"

または bvps.example.com の場合は、次のようになります。

set :subdomain, "btsp"

これを達成する簡単な方法はありますか?

4

1 に答える 1

0

あなたが探しているのは、Capistranoの多段階展開だと思います。wikiページはここにあります。あなたがしなければならないのは移動することだけです

set :subdomain, "atsp"

サーバー情報を含むファイル(つまり、config / deploy / atsp.rb)に追加すると、次のコマンドを使用してそのサーバーにデプロイできます。

cap atsp deploy

お役に立てれば。

于 2012-09-17T18:03:04.410 に答える