I am trying to configure the server with rails 5, Nginx and Puma. The application is running fine but Actioncable is giving
WebSocket connection to 'ws://server_name.com/cable' failed:
Error during WebSocket handshake: Unexpected response code: 200
Below are my nginx settings,
upstream app {
  server unix:/tmp/app.sock fail_timeout=0;
}
server {
    listen       80;
    server_name  server_name.com;
    try_files $uri/index.html $uri @app;
    client_max_body_size 100M;
    location @app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://app;
      client_max_body_size 10M;
    }
    location /cable {
       proxy_pass http://app/;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "Upgrade";
    }
    location ~ ^/(assets|uploads)/ {
        root assets_path;
        gzip_static on;
        expires max;
        add_header Cache-Control public;
        add_header ETag "";
        break;
    }
    error_page   500 502 503 504  /500.html;
 }
In rails in production.rb, I did the settings like below.
config.action_cable.url = 'ws://server_name.com/cable'
Any help will be appreciated.