0

/etc/nginx/nginx.conf好像:

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

这里我使用 gem foreman,它使用 upstart 来管理所有进程并用一个命令启动所有服务器

我在项目的主目录中创建了 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"

Ran bundle install local to edit Gemfile.lock 在服务器上部署的项目。

启动 Nginx

deploy@dcards101:/opt/nginx/conf$ sudo /etc/init.d/nginx stop   [ OK ]
deploy@dcards101:/opt/nginx/conf$ sudo /etc/init.d/nginx srart  [ OK ]

将数据从 Procfile 导出到 Upstart

deploy@dcards101:/var/www/cards/current$ rvmsudo foreman export upstart -a cards -u root

开始申请

deploy@dcards101:/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。

4

2 回答 2

0

我认为您的问题是您将应用服务器和 faye 服务器放在同一个上游!

如果我的上游和工头的方法正确,您的第一个访问者将获得第二个 faye 的应用程序,依此类推。(也许我错了,因为我不认识工头……但如果工头将所有可用服务器共享给所有服务,那可能是你的问题)

我说尝试 capistrano 而不是工头 .. 这样你就可以完全控制哪个服务器从哪里开始 .. 因为在我的主机上,http 不适用于 private_pub(因为 nginx)所以我必须安装 nginx_tcp_proxy_module 来获取 tcp 块在我的 nginx.conf 中工作

或者只是通过 ssh 逐个服务器尝试查找错误

于 2012-07-28T23:43:50.250 回答
0

得到同样的错误以这种方式解决:

首先安装 nginx_tcp_proxy_module

(我按照教程进行了操作,但将其更改为在 nginx 中使用乘客和瘦)

而不是将 tcp 部分添加到您的 nginx.conf 中:

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

不适用于我的 80 端口

之后我仍然从 faye/privat_pub 得到空的回复,但是有一个非常简单的解决方案:

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

看看private_pub - 问题 #29

现在一切正常,除了 chrome 如何触发 2 次

(我需要一个用于机架的守护进程)

希望它也能帮助你

于 2012-07-22T00:07:13.420 回答