2,270 Experience
22 Lessons Completed
0 Questions Solved


Posted in Action Cable with Puma, Nginx, Docker Swarm

All the tutorials I've found use puma for development and then passenger for production. But I wanted my environments to be the same!

Looking at the rails log and searching for /cable helped. The error message there seemed to indicate that nginx wasn't passing the right headers along, so I played around with the /etc/nginx/sites-available/mydomain.com file until something worked (see comment above). I'm not sure if all the settings I added are needed.

Posted in Action Cable with Puma, Nginx, Docker Swarm

I fixed this finally.

I updated my /etc/nginx/sites-available/mydomain.com with these additions. This is in the first server section under server_name

location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

location /cable {
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 also modified my config/production.rb The HOST variable is the domain name of my server.

config.action_cable.url = "wss://#{ENV['HOST']}/cable"
config.action_cable.allowed_request_origins = ["https://#{ENV['HOST']}"]

Posted in Action Cable with Puma, Nginx, Docker Swarm

I setup a DigitalOcean Ubuntu 22 droplet to host a docker swarm with containers for a rails app, postgress, and redis. I’m not able to get action cable to work with puma and nginx. I see errors in the console for: WebSocket connection to wss://mydomainname.com/cable

I followed their guides:
Setting up nginx as a reverse proxy:

Encrypting nginx:

Has anyone had any luck with a similar setup?

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2023 GoRails, LLC. All rights reserved.