Asked thg 9 14, 2021 2:11 CH 37 0 0
  • 37 0 0
0

[Ruby on Rails] Deploy action cable môi trường staging

Share
  • 37 0 0

Chào mọi người, hiện tại mình đang có vấn đề về việc deploy và sử dụng action cable thì bị fail
Lỗi sau: WebSocket connection to 'wss://domain/cable' failed: WebSocket is closed before the connection is established

Mình đã làm setup đầy đủ theo document và đây là config của mình (Rails 6 + nginx + puma):

  • cable.yml
staging:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL", "redis://localhost:6379/0") %>
  channel_prefix: app_staging
  • enviroments/staging.rb
  config.action_cable.url = 'wss://domain/cable'
  config.action_cable.allowed_request_origins = ['https://domain.com', 'http://domain.com']
  • Đây là file Nginx
location /cable {
    proxy_pass http://app;
    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_redirect off;
    proxy_set_header X-Forwarded-Proto $scheme;
  }

Mọi người có gì góp ý giúp mình phần này với ạ, mình đã thử nhiều cách trên google mà vẫn không được. Mình cảm ơn!

Viblo
Let's register a Viblo Account to get more interesting posts.