【发布时间】:2016-03-10 22:02:24
【问题描述】:
我正在尝试使用 Capistrano 将启用 Action Cable 的应用程序部署到 VPS。我正在使用 Puma、Nginx 和 Redis(用于 Cable)。经过几个障碍,我能够让它在本地开发环境中工作。我正在使用默认的进程内 /cable URL。但是,当我尝试将其部署到 VPS 时,我在 JS 日志中不断收到这两个错误:
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
在 JS-prompt 中打开 ActionCable.startDebugging() 没有显示任何感兴趣的内容。只是 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
请告知我任何可能有用的其他详细信息。
【问题讨论】:
标签: nginx puma ruby-on-rails-5