Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

nginx前置且设置proxy_set_header Upgrade时, vmess ws被主动探测path时返回异常 #147

Closed
SakuraSakuraSakuraChan opened this issue Sep 13, 2022 · 4 comments

Comments

@SakuraSakuraSakuraChan
Copy link

SakuraSakuraSakuraChan commented Sep 13, 2022

相关issue: #61

我跟上边issue的区别是他是wss我是ws,nginx只监听了80端口的,浏览器直接访问域名+path的话(https)返回是404,还算正常,但是改为http访问的话会弹出:
handshake error: bad "Upgrade" header
不知道能否顺手解决下呢

nginx配置:
server {
listen 80;
server_name fuck.gfw.com;
location /iloveverysimple {
proxy_redirect off;
proxy_pass http://127.0.0.1:23333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
location / {
return 302 https://fuck.gfw.com${request_uri};
}
}

@SakuraSakuraSakuraChan SakuraSakuraSakuraChan added the bug Something isn't working label Sep 13, 2022
@e1732a364fed
Copy link
Owner

你是 vs前置监听443,然后转发到nginx的80?如果是这样,你直接访问http不就是直接访问nginx吗,那vs也捕获不到啊?

@SakuraSakuraSakuraChan
Copy link
Author

你是 vs前置监听443,然后转发到nginx的80?如果是这样,你直接访问http不就是直接访问nginx吗,那vs也捕获不到啊?

我是nginx直接监听80的ws然后转发给VS

@e1732a364fed
Copy link
Owner

handshake error: bad "Upgrade" header 应该是一个比较正常的响应之一,符合你现在的情况。

你现在是nginx前置,nginx虽然设置了Connection,但是却没设置好Upgrade,因为它的Upgrade是跟随 客户端请求的,即 $http_upgrade, 而你随便访问网页,客户端显然不会设置Upgrade字段,因此 我们的ws就会察觉到这并不是正常的websocket响应。

@e1732a364fed
Copy link
Owner

解决办法很简单,你把nginx的 下面两行配置去掉:

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

总之这不算vs的bug。

@e1732a364fed e1732a364fed removed the bug Something isn't working label Sep 14, 2022
@e1732a364fed e1732a364fed changed the title [Bug] vmess ws主动探测path返回异常 nginx前置且设置proxy_set_header Upgrade时, vmess ws被主动探测path时返回异常 Sep 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants