[Ruby on Rails] Deploy action cable môi trường staging
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!
1 CÂU TRẢ LỜI
Hey everyone, I've been seeing a lot of folks here talking about the technical side of things, and it reminds me how sometimes you just need a break to unwind. Lately, I've found myself getting lost in playing Tiny Fishing. It's so chill, especially when you finally upgrade your gear and land one of those super rare, elusive fish. It's a nice way to clear my head after grappling with tricky deployments or errors. Speaking of which, for those of you dealing with WebSocket issues, have you considered if any specific firewall rules might be interfering with your wss:// connections?