2012-07-17 45 views
0

/etc/nginx/nginx.conf的Nginx服務器的配置是這樣的:薄,王菲和Redis的

user deploy; 
worker_processes 5; 

error_log logs/error.log; 

events { 
    worker_connections 1024; 
    use epoll; 
} 

http { 

    include  mime.types; 
    default_type application/octet-stream; 


    sendfile  on; 

    keepalive_timeout 65; 

    upstream foreman4000 { 
     server x.x.x.x:4000; 
     server x.x.x.x:4001; 
     server x.x.x.x:4002; 
     server x.x.x.x:4003; 
     server x.x.x.x:4004; 
    } 

    server { 
     listen  80; 
     server_name x.x.x.x; #server IP 
     access_log /opt/nginx/foreman4000.access.log; 
     location/{ 
     proxy_pass http://foreman4000; 
     proxy_set_header Host $host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $remote_addr; 
     } 
    } 
} 

這裏我用的寶石工頭,它採用新貴來管理所有的過程和啓動所有服務器使用一個命令

我創建Procfile在該項目的主目錄包含:

redis: redis-server 
thin: bundle exec thin start -p $PORT 
faye: rackup faye.ru -E production -s thin 

加入Gemfile中:

gem 'foreman' 
gem 'thin' 
gem "foreman-export-daemontools", "~> 0.0.1" 

冉捆綁安裝在本地服務器上編輯Gemfile.lock的 部署項目。

開始Nginx的

[email protected]:/opt/nginx/conf$ sudo /etc/init.d/nginx stop [ OK ] 
[email protected]:/opt/nginx/conf$ sudo /etc/init.d/nginx srart [ OK ] 
從Procfile

導出的數據新貴

[email protected]:/var/www/cards/current$ rvmsudo foreman export upstart -a cards -u root 

啓動的應用

[email protected]:/var/www/cards/current$ rvmsudo start cards 

現在一切都必須是好的,但我所看到的在服務器上只

502 Bad Gateway 

nginx/1.0.15 

日誌說:

2012/07/17 17:22:30 [error] 11593#0: *148 no live upstreams while connecting to upstream, client: x.x.x.x, server: x.x.x.x, request: "GET/HTTP/1.1", upstream: "http://foreman4000/", host: "x.x.x.x" 

請什麼能幫到你。服務器 - Ubuntu 10 LTS。

回答

0

得到了同樣的錯誤解決這樣說:

先安裝nginx_tcp_proxy_module

(我跟着this教程,但改變了它使用的乘客又瘦,nginx的)

比TCP部件添加到您nginx.conf:在端口80

tcp { 
    upstream websockets { 
     ## node processes 
     server 12.34.56.78:9292; 
     check interval=300 rise=2 fall=5 timeout=1000; 
    } 

    server { 
     listen 9200; 
     server_name domain.org; 
     tcp_nodelay on; 
     proxy_pass websockets; 
    } 
} 

doesn't工作對我來說

後,我仍然得到王菲/ privat_pub空的答覆,但有一個的極端平凡解:

RAILS_ENV=production bundle exec rackup private_pub.ru -s thin -E production 

private_pub - Issue #29

現在一切正常,除了Chrome瀏覽器如何大火2次

(和我需要一個deamon進程的機架)

希望它可以幫助你

+0

非常感謝你,但它不完全是我所需要的。我想我的錯在上游的某處,在rails服務器上。但我找不到有什麼問題。如果我可以開始瘦身,我想所有事情都應該是可以的。 – 2012-07-24 10:05:40

0

我認爲你的問題是你把你的app-server和faye服務器放在同一個上游!

如果我得到上游和工頭的權利的方法,您的第一個訪客得到應用程序的第二個faye等。 (也許我錯了,因爲我不知道工頭..但如果工頭共享所有可用的服務器到所有服務,這可能是你的問題)

我木頭說,嘗試capistrano而不是工頭..所以你有充分控制哪個服務器啓動的地方..因爲在我的主機http不會爲private_pub工作(因爲nginx),所以我不得不安裝nginx_tcp_proxy_module來獲得工作在我的nginx.conf中的tcp塊

或者只是嘗試服務器通過服務器通過ssh找到錯誤