且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Websocket-rails在Nginx和Unicorn的生产环境中不起作用

更新时间:2023-11-22 18:58:40

您的nginx配置将/websocket/以下的请求与结尾的/进行匹配.这是/websocket/blah的目录组件.

Your nginx config is matching requests below /websocket/ with the trailing /. That is the directory component of /websocket/blah.

如果您查看nginx访问日志文件,则会发现您对/websocket的请求正被301重定向到/websocket/.

If you look in your nginx access log file you'll find your requests to /websocket are being 301 redirected to /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";
}