4

nginx, unicorn 및 capistrano를 사용하여 오류없이 vios 시스템에 내 rials 앱을 배포 할 수있었습니다. 자, 같은 vginx 서버 내에서 동일한 nginx config (두 스크립트는 아래에 있음)를 사용하여 다른 레일 응용 프로그램을 배포하려고합니다. 설치 및 캡 배치 : 콜드가 올바르게 설정되고 레일 응용 프로그램이 섬기는 사람. 내가 얻는 문제는 이것이다. 내가 service nginx restart를 입력 할 때 나는 현재 실행중인 첫 번째 응용 프로그램 내 nginx를 스크립트가 실행 대신 trows에 실패 번째 레일 응용 프로그램에 대한레일에 unicorn, nginx 및 capistrano가있는 가상 호스트 설정

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의 설정이

nginx: [emerg] duplicate upstream "unicorn" in /etc/nginx/sites-enabled/cf:1 
nginx: configuration file /etc/nginx/nginx.conf test failed 

다음과 같은 오류를 얻을 처음에 오류가 응용 프로그램을 레일과 충돌을하게

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; 
} 

내가이 문제를 해결하고 올바르게 가상 호스트를 설정하는 방법에 어떤 아이디어입니다. 고맙습니다.

답변

10

업스트림 이름을 다르게 지정합니다 (업스트림 이름은 고유해야 함). 따라서 unicorn 대신 @my_shiny_app_server이라는 이름을 사용하십시오. 그런 다음이 이름 proxy_pass 지시문 http://my_shiny_app_server을 사용하십시오. my_shiny 문자열을 앱 이름으로 바꿉니다. 예 : gutrees, cf.

+0

멋진. 이 첫 번째 오류가 해결되었습니다. 새로운 오류는 'nginx : 설정 파일 /etc/nginx/nginx.conf test failed'입니다. 또한 두 번째 앱의 @unicorn 변수를 @gutrees로 업데이트했습니다. 나는 그걸 생각하고 있니? – Uchenna

+0

두 번째 오류는 서버에 배포 한 후에도 계속 발생하며 실행중인 첫 번째 앱에 대한 URL을 입력하면 충돌합니다. – Uchenna

관련 문제