Proxy for web socket

2025-08-22 linux raspi rails

To enable WebSocket feature(ActionCable) under Apache HTTP server on RaspberryPiOS. I needed 3 steps.

Enable the module.

sudo a2enmod proxy_wstunnel

Add proxy settings on apache conf under /etc/apache2/sites-available.

ProxyPass /cable ws://localhost:3000/cable
ProxyPassReverse /cable ws://localhost:3000/cable

Need to allow the access explicitly For Ruby on Rails. Edit config/environments/production.rb.

config.action_cable.allowed_request_origins = [ 'https://yourdomain.net' ]

Ref: https://www.otsuka-bs.co.jp/web-creation/blog/archive/20241106-01.html