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

Posted November 27, 2020 3.2k views
Ruby on RailsNginx

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 :-)

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.

Submit an Answer
1 answer
proxy_set_header        X-Forwarded-Proto $scheme;
proxy_set_header        X-Forwarded-Host $host;