繁体   English   中英

ActionCable - Puma - Nginx - SSL

[英]ActionCable - Puma - Nginx - SSL

我对 ActionCable 完全陌生...试图在 Rails 6.0 应用程序(Nginx + Puma)上设置 Action cable。 我还不得不说我的环境是在云上(DigitalOcean.com),那就是 SSL。

我的配置/cable.yml:

development:
  adapter: redis
  url: redis://localhost:6379

我的 config/environments/development.rb:我刚刚添加了这些行

config.action_cable.allowed_request_origins = ["https://my.url.com/"]
config.action_cable.url = "ws://localhost:3000/cable"

当然:my.url.com 是我的域名。

我收到此错误:

WebSocket connection to 'wss://my.url.com/cable' failed: WebSocket is closed before the connection is established.

有人有想法吗?

非常感谢:-)

将位置块添加到 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";

}

puma_app替换为您的上游名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM