title: How to configure ActionCable with Nginx and Unicorn in production?
body: <p>I've recently switched my rails project from Rails4 to 5.0.0.beta3 to use the awesome ActionCable.</p>
  
  <p>My ActionCable server is run inside unicorn. In development all works fine. In production I have
   </p>
  
  <pre><code>Started GET "/cable" for xxx.xxx.xxx.xxx at 2016-03-28 18:06:38 +0300
  Started GET "/cable/" [WebSocket] for xxx.xxx.xxx.xxx at 2016-03-28 18:06
  Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
  Registered connection (189772ff-6229-48f1-ae7f-d9a96ad3a6c3)
  Finished "/cable/" [WebSocket] for xxx.xxx.xxx.xxx at 2016-03-28 18:06:35
  </code></pre>
  
  <p>And this message repeats again and again in a loop.</p>
  
  <p>I've tried a lot of options at stackoverflow to handle this but nothing helps.
  My nginx config:
  </p>
  
  <pre><code> upstream unicorn {
     server unix:/tmp/unicorn.my_app.sock fail_timeout=0;
   }
  
   server {
     server_name www.my_app.com;
     return 301 $scheme://my_app.com$request_uri;
   }
  
   server {
     listen 80 default deferred;
     server_name my_app.com;
     root /var/www/my_app/current/public;
  
     location ^~ /assets/ {
       gzip_static on;
       expires max;
       add_header Cache-Control public;
     }
  
     try_files $uri/index.html $uri @unicorn;
     location @unicorn {
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header Host $http_host;
       proxy_redirect off;
       proxy_pass http://unicorn;
     }
  
     location /cable {
       proxy_pass http://unicorn/cable;
       proxy_http_version 1.1;
       proxy_set_header Upgrade websocket;
       proxy_set_header Connection Upgrade;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }
  
     error_page 500 502 503 504 /500.html;
     keepalive_timeout 5;
   }
  </code></pre>
  
  <p>To be sure that request is allowed I've temporarily use this code in initializers:
  <code>ActionCable.server.config.disable_request_forgery_protection = true</code></p>
  
  <p>My <code>cable.coffee</code> file
  </p>
  
  <pre><code> @App ||= {}
   App.cable = ActionCable.createConsumer "/cable"
  </code></pre>
  
  <p>My <code>config/cable.yml</code> file
  </p>
  
  <pre><code>production:
   adapter: redis
   url: redis://localhost:6379/1
  </code></pre>
  
  <p>I'm not so experienced at this question, so any help would be great.</p>