我正在尝试使用Capistrano将Action Cable -enabled-application部署到VPS。我使用的是Puma,Nginx和Redis(用于Cable)。经过几次跨栏后,我能够在当地的发展环境中工作。我正在使用默认的进程内/有线URL。但是,当我尝试将其部署到VPS时,我不断在JS-log中得到这两个错误:
Establishing connection to host ws://{server-ip}/cable failed.
Connection to host ws://{server-ip}/cable was interrupted while loading the page.
并在我的应用程序特定 nginx.error.log
我收到这些消息:
2016/03/10 16:40:34 [info] 14473#0: *22 client 90.27.197.34 closed keepalive connection
开启 ActionCable.startDebugging()
在JS-prompt中没有显示任何兴趣。只是ConnectionMonitor尝试无限期地重新打开连接。我也得到了301的负载:永久移动 - 在我的网络监视器中请求/ cable。
我尝试过的事情:
- 使用
async
适配器而不是Redis。 (这是开发环境中使用的) 添加这样的东西到我的
/etc/nginx/sites-enabled/{app-name}
:location /cable/ { proxy_pass http://puma; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }
设置
Rails.application.config.action_cable.allowed_request_origins
到正确的主机(尝试“http:// {server-ip}”和“ws:// {server-ip}”)- 开启
Rails.application.config.action_cable.disable_request_forgery_protection
没有运气。是什么导致了这个问题?
$ rails -v
Rails 5.0.0.beta3
请告知我可能有用的任何其他详细信息。