Ruby on rails 带有主应用程序的WebSocket(nginx&x2B;passenger+;faye)

Ruby on rails 带有主应用程序的WebSocket(nginx&x2B;passenger+;faye),ruby-on-rails,nginx,websocket,passenger,faye,Ruby On Rails,Nginx,Websocket,Passenger,Faye,我正在尝试在rails应用程序上设置WebSocket。我的应用程序与使用SocketRocker库的iOS客户端配合使用 作为WebSocket后端,我使用gem。 它作为机架中间件集成到rails应用程序中 config.middleware.delete Rack::Lock config.middleware.use FayeRails::Middleware, mount: '/ws', server: 'passenger', engine: {type: Faye::Redis,

我正在尝试在rails应用程序上设置WebSocket。我的应用程序与使用SocketRocker库的iOS客户端配合使用

作为WebSocket后端,我使用gem。 它作为机架中间件集成到rails应用程序中

config.middleware.delete Rack::Lock
config.middleware.use FayeRails::Middleware, mount: '/ws', server: 'passenger', engine: {type: Faye::Redis, uri: redis_uri}, :timeout => 25 do
  map default: :block
end
在我使用Nginx将其上传到生产服务器之前,它工作得非常好。我尝试了很多解决方案来将websocket请求传递到后端,但没有成功。主要是有两台服务器在运行,但我只有一台。我的想法是,我只需要将请求从/faye端点代理到/ws(以更新头)。在我的例子中,什么是正确的代理传递参数

    location /faye {
    proxy_pass http://$server_name/ws;
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }

我有一个类似的问题,经过一段时间的努力,我终于可以让它工作了

我正在使用nginx1.8thin服务器以及gem'fayerails,我的挂载点是/faye

我的nginx配置如下所示:

upstream thin_server {
    server 127.0.0.1:3000;
}

map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
}

server {
    ...   
    proxy_redirect off; 
    proxy_cache off;     

    location = /faye {
        proxy_pass http://thin_server;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        chunked_transfer_encoding off;
        proxy_buffering off;
        proxy_cache off;
    }

    location / {
        try_files $uri/index.html $uri.html $uri @proxy;
    }

    location @proxy {
        proxy_pass http://thin_server;
        proxy_set_header  X-Real-IP  $remote_addr;                      
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;   
        proxy_set_header  Host $http_host;                              
    }                                                            
    ...
}                                                  
最后一个转折点是设置“location=/faye”。在我尝试“location/faye”和“location~/faye”之前,它失败了。
看起来等号“=”阻止了nginx与其他位置设置混合。

解决这个问题有什么运气吗?我现在也遇到了类似的问题。我停止使用中间件,单独启动socket服务器。我想这正是我要做的。非常感谢。