Rails 5 Action Cable deployment with Nginx, Puma & Redis
<p>I am trying to deploy an Action Cable -enabled-application to a VPS using Capistrano. I am using Puma, Nginx, and Redis (for Cable). After a couple hurdles, I was able to get it working in a local developement environment. I'm using the default in-process /cable URL. But, when I try deploying it to the VPS, I keep getting these two errors in the JS-log:</p>

<pre><code>Establishing connection to host ws://{server-ip}/cable failed.
Connection to host ws://{server-ip}/cable was interrupted while loading the page.
</code></pre>

<p>And in my app-specific <code>nginx.error.log</code> I'm getting these messages:</p>

<pre><code>2016/03/10 16:40:34 [info] 14473#0: *22 client 90.27.197.34 closed keepalive connection
</code></pre>

<p>Turning on <code>ActionCable.startDebugging()</code> in the JS-prompt shows nothing of interest. Just ConnectionMonitor trying to reopen the connection indefinitely. I'm also getting a load of 301: Moved permanently -requests for /cable in my network monitor.</p>

<h3>Things I've tried:</h3>

<ul>
<li>Using the <code>async</code> adapter instead of Redis. (This is what is used in the developement env)</li>
<li><p>Adding something like this to my <code>/etc/nginx/sites-enabled/{app-name}</code>:</p>

<pre><code>location /cable/ {
  proxy_pass http://puma;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "Upgrade";
}
</code></pre></li>
<li><p>Setting <code>Rails.application.config.action_cable.allowed_request_origins</code> to the proper host (tried "http://{server-ip}" and "ws://{server-ip}")</p></li>
<li>Turning on <code>Rails.application.config.action_cable.disable_request_forgery_protection</code></li>
</ul>

<p>No luck. What is causing the issue?</p>

<pre><code>$ rails -v
Rails 5.0.0.beta3
</code></pre>

<p>Please inform me of any additional details that may be useful.</p>