Merge branch 'develop' of gitee.com:fusenpack/fusenapi into develop

This commit is contained in:
laodaming 2023-08-21 15:30:59 +08:00
commit 1b04ac57e5
2 changed files with 9 additions and 8 deletions

View File

@ -81,6 +81,12 @@ func main() {
fs := http.FileServer(http.Dir(vueBuild))
indexHtmlPath := vueBuild + "/index.html"
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
err := r.ParseMultipartForm(100 << 20)
if err != nil {
log.Println(err)
}
if strings.HasPrefix(r.URL.Path, "/api/") {
// 对/api开头的请求进行反向代理
proxy := httputil.NewSingleHostReverseProxy(apiURL)
@ -144,18 +150,10 @@ func NewBackend(mux *http.ServeMux, httpAddress string, muxPaths ...string) *Bac
},
}
dialer := &websocket.Dialer{
Proxy: http.ProxyFromEnvironment,
NetDial: func(network, addr string) (net.Conn, error) {
return net.Dial(network, addr)
},
}
// 创建后端服务对象,包含地址和客户端
backend := &Backend{
HttpAddress: httpAddress,
Client: client,
Dialer: dialer,
}
// 创建处理请求的函数
@ -192,6 +190,7 @@ func NewBackend(mux *http.ServeMux, httpAddress string, muxPaths ...string) *Bac
header.Del("Sec-Websocket-Key")
header.Del("Sec-Websocket-Version")
header.Del("Connection")
// header.Del("Origin")
proxyConn, _, err := backend.Dialer.Dial(target.String(), header)
if err != nil {

View File

@ -22,6 +22,8 @@ run_server() {
cd - > /dev/null
}
find /tmp/go-build* -mmin +5 -delete
# 列出所有服务器目录
server_dirs=() # 初始化一个空数组