我尝试部署我的Rails应用程序,该应用程序包含与Puma和Nginx的Actioncable。
所以我从浏览器
!**/build
然后,当我检查nginx错误日志时,我得到了这个
这是我的nginx配置文件
WebSocket connection to 'ws://sub.domain.com/cable' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
我的puma.rb
upstream puma {
server unix:///home/deploy/apps/app_repo/shared/tmp/sockets/app_repo-puma.sock;
}
server {
listen 80 default deferred;
server_name sub.domain.com;
root /home/deploy/apps/app_repo/current/public;
access_log /home/deploy/apps/app_repo/current/log/nginx.access.log;
error_log /home/deploy/apps/app_repo/current/log/nginx.error.log info;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
# enables WS support
location /cable {
proxy_pass http://puma;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 180;
}
try_files $uri/index.html $uri @puma;
location @puma {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 180;
proxy_pass http://puma;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 180;
}
那么如何解决这个问题并让Actioncable在prodeuction服务器上运行良好呢?
非常感谢你。