Closed lyj0309 closed 1 year ago
location /xxx/ {
proxy_set_header X-Real-IP $remote_addr; # 该头部与config.js文件的 proxy.header 对应
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:9527;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
与
location /xxx/ { # 该规则用于代理路径下的http请求
proxy_set_header X-Real-IP $remote_addr; # 该头部与config.js文件的 proxy.header 对应
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Connection "";
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://127.0.0.1:9527;
proxy_redirect default;
}
location /xxx { # 该规则用于代理路径下的ws请求
proxy_set_header X-Real-IP $remote_addr; # 该头部与config.js文件的 proxy.header 对应
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Nginx-Proxy true;
proxy_pass http://127.0.0.1:9527;
proxy_redirect default;
}
还是有区别的,访问/xxx
会触发301重定向到/xxx/
,PC端会连接失败:
location /xxx {
proxy_set_header X-Real-IP $remote_addr; # 该头部与config.js文件的 proxy.header 对应
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:9527;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
这样的话,吧 /xxx/ 改成 /xxx 应该就不会有问题了吧
/xxx
的话,匹配范围会被意外扩大,例如/xxxaa
会被匹配,只要以这个前缀开头的路径都会被匹配,所以也不建议这样写
确实哈,我能想到的解决方案是改代码,加个判断,301就继续访问新地址
24 由于node不会自动下载中间证书,但浏览器会,所以就算你的网站https浏览器认了,node也不一定认,会报错,详情
https://stackoverflow.com/questions/20082893/unable-to-verify-leaf-signature
使用nginx新版websocket写法,可以让http和websocket二合一
http://nginx.org/en/docs/http/websocket.html