Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[错误]Websocket 反代到子目录异常 #93

Closed
Potatoii opened this issue Apr 29, 2024 · 8 comments
Closed

[错误]Websocket 反代到子目录异常 #93

Potatoii opened this issue Apr 29, 2024 · 8 comments

Comments

@Potatoii
Copy link

错误来源

Stapxs QQ Lite

描述错误

网页端wss连接可以发出去, 但是连接握手之后就没有然后了

复现流程

llob的后端, 用nginx反代出来的wss, 点击连接可以成功创建websocket连接, 但是页面没有反应

截图

image

版本信息

2.7.2

更多

No response

@Stapxs
Copy link
Owner

Stapxs commented Apr 29, 2024

写完整 wss:// 试试(
自动判断 SSL 写的有点问题一直都没改好

@Potatoii
Copy link
Author

wss的判断倒是对的, 页面确实发起了wss的连接, 后端也收到了, 然后就没有下一步了..

@Stapxs
Copy link
Owner

Stapxs commented Apr 29, 2024

🤔

@Stapxs
Copy link
Owner

Stapxs commented Apr 29, 2024

没复现出来,可以的话可以看一下 nginx 的反代设置吗

@Potatoii
Copy link
Author

location /ws {
proxy_pass http://192.168.31.253:3011;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

@Stapxs
Copy link
Owner

Stapxs commented Apr 29, 2024

哦,我之前也遇到过这个问题,反代到子目录下之后连上了 ws 但是完全不交互……
不是 sql 自己的问题
暂时没搞清楚是什么问题,可以先不往子目录代

@Stapxs
Copy link
Owner

Stapxs commented Apr 29, 2024

问了下作者解决了(x
参考一下,proxy_pass 加个 rewrite 把 ws 子目录重写掉就好了

location ^~ /ws {
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  
  rewrite ^/ws /$1 break;
  proxy_pass http://frps:3010;
}

@Potatoii
Copy link
Author

我超, 确实解决了, 牛!

@Stapxs Stapxs changed the title [错误]网页端一些问题 [错误]Websocket 反代到字目录异常 Apr 29, 2024
@Stapxs Stapxs changed the title [错误]Websocket 反代到字目录异常 [错误]Websocket 反代到子目录异常 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants