rails 5,NGSX WebSocket握手期间出错:意外的响应代码:404

时间:2016-11-05 18:35:04

标签: nginx websocket ruby-on-rails-5 puma

我尝试将简单的网络聊天部署到服务器(nginx / puma)。但是我收到了浏览器的错误控制台:

WebSocket connection to 'ws://domain.com/cable' failed: Error during WebSocket handshake: Unexpected response code: 404

我的配置服务器domain.conf:

upstream backend {
  server unix:///var/run/backend.sock;
}

server {
  listen 80 ;
  server_name domain.com;

  root /home/rails/backend/public;
  access_log /home/rails/backend/log/nginx.access.log;
  error_log /home/rails/backend/log/nginx.error.log info;

  try_files $uri/index.html $uri @backend;
  location @backend {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;

    proxy_pass http://backend;
  }

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  location /cable {
        proxy_pass http://gifty;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
      }
}

某些地方出错了吗? AnyOne之前设置它。请帮我搞清楚

0 个答案:

没有答案