Добрый день! Я хочу запустить приложение websocket с драгоценным камнем Faye, но возникает следующая проблема: при развертывании моего приложения на рабочем сервере Ngix не может получать faye.js и не может подключиться к серверу faye. В Nginx error.log я обнаружил следующие ошибки:Ошибки Nginx с Rails + Faye + Puma на Dokku Digital Ocean
2014/12/24 15:44:39 [error] upstream prematurely closed connection while reading response header from upstream, client: 46.0.121.23, server: example.com, request: "GET /faye HTTP/1.1", upstream: "http://127.0.0.1:9292/faye", host: "example.com"
2014/12/24 15:44:39 [error] *1 connect() failed (111: Connection refused) while connecting to upstream, client: 46.0.121.23, server: example.com, request: "GET /faye HTTP/1.1", upstream: "http://127.0.0.1:9292/faye", host: "example.com"
я попробовать How to start faye server on a rails app deployed using dokku? и Error 502 Bad Gateway on NGINX + rails + dokku ответы, но это не помогает мне.
Мои PROCFILE является
web: bundle exec rails s Puma -p 5000
faye: bundle exec rackup s Puma faye.ru
Мой faye.ru является
require 'faye'
require File.expand_path('../config/initializers/faye_token.rb', __FILE__)
class ServerAuth
def incoming(message, callback)
if message['channel'] !~ %r{^/meta/}
if message['ext']['auth_token'] != FAYE_TOKEN
message['error'] = 'Invalid authentication token.'
end
end
callback.call(message)
end
end
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 0)
faye_server.add_extension(ServerAuth.new)
run faye_server
Мой nginx.conf является:
upstream example.com { server 127.0.0.1:49169; }
server {
listen [::]:80;
listen 80;
server_name example.com;
location /{
proxy_pass http://example.com;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Request-Start $msec;
}
location /faye {
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_buffering off;
proxy_cache_bypass $http_pragma $http_authorization;
proxy_no_cache $http_pragma $http_authorization;
proxy_pass http://localhost:9292;
}
}
Мое приложение получить faye.js следующий:
<%= javascript_include_tag "http://example.com/faye.js" %>
И подключиться к серверу Фей
$(function() {
var faye = new Faye.Client('http://example.com/faye');
faye.subscribe('/comments/new', function (data) {
eval(data);
});
});
Что я могу сделать? В разработке среды все работает нормально, но в производстве только ошибки.