This is an example of how to configure nginx to allow ActionCable WebSocket connections to use the same host as your primary site. For example, instead of cable.myapp.dev
, you can use myapp.dev/_c/
.
In my case, we have a multi-tenanted environment, e.g., bob.myapp.dev
and jim.myapp.dev
. This lets the ActionCable connection still use the Host:
header to select a tenant, and use normal cookies for user identification. wss://bob.myapp.dev/_c/
is authorized as normal. It also piggybacks off of whatever TLS setup is available.
Thank you.