Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionCable - Puma - Nginx - SSL

I'm totally new to ActionCable... Trying to set up Action cable on a Rails 6.0 application (Nginx + Puma). I also have to say my environment is on the cloud (DigitalOcean.com), and that is SSL.

My config/cable.yml :

development:
  adapter: redis
  url: redis://localhost:6379

My config/environments/development.rb : i've just added this lines

config.action_cable.allowed_request_origins = ["https://my.url.com/"]
config.action_cable.url = "ws://localhost:3000/cable"

Of course: my.url.com is my domain.

I'm getting this error :

WebSocket connection to 'wss://my.url.com/cable' failed: WebSocket is closed before the connection is established.

Does anyone have a idea ?

Thanks a lot :-)

like image 867
Geo Avatar asked Sep 07 '25 09:09

Geo


1 Answers

Add a location block to your nginx configuration file.

location /cable {
 proxy_pass http://puma_app;
 proxy_http_version 1.1;
 proxy_set_header X-Forwarded-Proto https;
 proxy_set_header X-Forwarded-Ssl on;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "upgrade";

}

Replace puma_app with your upstream name.

like image 90
Abhishek Aravindan Avatar answered Sep 10 '25 04:09

Abhishek Aravindan