![](/img/trans.png)
[英]ActionCable doesn't work with Unicorn in Rails production server (nginx)
[英]Websocket-rails doesn't work on production evironment with Nginx and Unicorn
我有使用gem websocket-rails 0.7的Rails 3.2應用程序。
在開發機器上,一切正常
在生產環境中,我使用Nginx / 1.6作為代理服務器,使用Unicorn作為http服務器。 Thin用於獨立模式(遵循https://github.com/websocket-rails/websocket-rails/wiki/Standalone-Server-Mode )。
nginx配置:
location /websocket {
proxy_pass http://localhost:3001/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
在后端方面,我有以下代碼用於向客戶發送通知
WebsocketRails[:callback_requests].trigger 'new', call_request
在客戶端,我使用以下連接:
dispatcher = new WebSocketRails window.location.host + ':3001/websocket'
channel = dispatcher.subscribe 'callback_requests'
但通知不會發給客戶。
關於github的相關問題 - github.com/websocket-rails/websocket-rails/issues/211
你的nginx
配置匹配/websocket/
下面的請求與尾隨/
。 那是/websocket/blah
的目錄組件。
如果你查看你的nginx
訪問日志文件,你會發現你對/websocket
的請求被重定向到/websocket/
。
刪除尾隨/
location /websocket {
proxy_pass http://localhost:3001/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.