簡體   English   中英

在rails中設置一個帶有unicorn,nginx和capistrano的虛擬主機

[英]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字符串替換為應用程序的名稱,例如gutreescf

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM