我正在尝试使用Capistrano将一个启用Action电缆的应用程序部署到VPS中。我正在使用美洲豹,Nginx和Redis (电缆)。经过几个障碍之后,我能够让它在当地的开发环境中工作。我使用的是默认的进程内/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提示符中打开ActionCable.startDebugging()没有任何意义。只是ConnectionMonitor试图无限期地重新打开连接。我还得到了301的负载:在我的网络监视器中为/cable永久移动了/cable。
我尝试过的事情:
async适配器而不是Redis。(这是developement env中使用的内容)/etc/nginx/sites-enabled/{app-name}中:
位置/电缆/{ proxy_pass http://puma;proxy_http_version 1.1;proxy_set_header升级$http_upgrade;proxy_set_header连接“升级”;}Rails.application.config.action_cable.allowed_request_origins设置为适当的主机(尝试了"http://{server-ip}“和”ws://{server}“)Rails.application.config.action_cable.disable_request_forgery_protection不走运。是什么引起了这个问题?
$ rails -v
Rails 5.0.0.beta3请告诉我任何可能有用的额外细节。
发布于 2016-03-16 18:45:31
终于,我开始工作了!我已经尝试了一周了.
301重定向是由于nginx实际上试图将浏览器重定向到/cable/而不是/cable造成的。这是因为我在location节中指定了/线缆/而不是location!我是从this answer那里得到这个想法的。
https://stackoverflow.com/questions/35928227
复制相似问题