[英]ActionCable - Puma - Nginx - SSL
I'm totally new to ActionCable... Trying to set up Action cable on a Rails 6.0 application (Nginx + Puma).我对 ActionCable 完全陌生...试图在 Rails 6.0 应用程序(Nginx + Puma)上设置 Action cable。 I also have to say my environment is on the cloud (DigitalOcean.com), and that is SSL.
我还不得不说我的环境是在云上(DigitalOcean.com),那就是 SSL。
My config/cable.yml:我的配置/cable.yml:
development:
adapter: redis
url: redis://localhost:6379
My config/environments/development.rb: i've just added this lines我的 config/environments/development.rb:我刚刚添加了这些行
config.action_cable.allowed_request_origins = ["https://my.url.com/"]
config.action_cable.url = "ws://localhost:3000/cable"
Of course: my.url.com is my domain.当然:my.url.com 是我的域名。
I'm getting this error:我收到此错误:
WebSocket connection to 'wss://my.url.com/cable' failed: WebSocket is closed before the connection is established.
Does anyone have a idea?有人有想法吗?
Thanks a lot:-)非常感谢:-)
Add a location block to your nginx configuration file.将位置块添加到 nginx 配置文件。
location /cable {
proxy_pass http://puma_app;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
} }
Replace puma_app
with your upstream name.将
puma_app
替换为您的上游名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.