How to configure Redis/ActionCable on Nginx/Puma server ?

My droplet : Ruby on Rails on Ubuntu 20.04 | Nginx | Puma | SSL

I’m totally new to ActionCable, and trying to set up Actioncable on my Rails application.

My config/cable.yml :

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

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

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

Of course: is my domain.

My Nginx

upstream websocket {

server {


  location /cable {
    proxy_pass https://websocket/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto https;
    proxy_redirect off;

I’m getting this error :

WebSocket connection to 'wss://' failed: WebSocket is closed before the connection is established.

Does anyone have a idea ?

Thanks a lot :-)


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

proxy_set_header        X-Forwarded-Proto $scheme;
proxy_set_header        X-Forwarded-Host $host;