Ruby on rails 轨道&x2B;ActionCable&x2B;Nginx+;独角兽设置
我一直在尝试使用Nginx+Unicorn在Ubuntu中部署Rails 5+ActionCable应用程序 正常的http请求工作正常,但Websockets连接被拒绝,我想这是我的Nginx的一个问题 我一直在想谷歌,发现了类似的问题和解决方案,但似乎什么都不起作用: - - - 我甚至尝试为nginx和websockets调整NodeJS设置 我得到的错误是“ws://mydomain.com/cable”失败:WebSocket握手期间出错:404Ruby on rails 轨道&x2B;ActionCable&x2B;Nginx+;独角兽设置,ruby-on-rails,nginx,unicorn,actioncable,Ruby On Rails,Nginx,Unicorn,Actioncable,我一直在尝试使用Nginx+Unicorn在Ubuntu中部署Rails 5+ActionCable应用程序 正常的http请求工作正常,但Websockets连接被拒绝,我想这是我的Nginx的一个问题 我一直在想谷歌,发现了类似的问题和解决方案,但似乎什么都不起作用: - - - 我甚至尝试为nginx和websockets调整NodeJS设置 我得到的错误是“ws://mydomain.com/cable”失败:WebSocket握手期间出错:404 upstream app_serve
upstream app_server {
server unix:/var/run/unicorn.sock fail_timeout=0;
}
server {
listen 80;
root /home/rails/rails_project/public;
server_name _;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|ta$
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
location /cable {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://app_server;
}
}
提前感谢修复了我的设置中类似的错误(actioncable/cable中的404)
location /cable {
proxy_pass http://unix:/home/app/shared/tmp/puma/socket;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}