From bb912d6c37e0e1156667eea30cb74767e9f06a48 Mon Sep 17 00:00:00 2001 From: Sword Date: Fri, 13 Dec 2024 14:37:07 +0800 Subject: [PATCH] enable h2c for vhost server (#4582) --- pkg/util/vhost/http.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/util/vhost/http.go b/pkg/util/vhost/http.go index 30f9631e..bc458a5c 100644 --- a/pkg/util/vhost/http.go +++ b/pkg/util/vhost/http.go @@ -29,6 +29,8 @@ import ( libio "github.com/fatedier/golib/io" "github.com/fatedier/golib/pool" + "golang.org/x/net/http2" + "golang.org/x/net/http2/h2c" httppkg "github.com/fatedier/frp/pkg/util/http" "github.com/fatedier/frp/pkg/util/log" @@ -41,7 +43,7 @@ type HTTPReverseProxyOptions struct { } type HTTPReverseProxy struct { - proxy *httputil.ReverseProxy + proxy http.Handler vhostRouter *Routers responseHeaderTimeout time.Duration @@ -138,7 +140,7 @@ func NewHTTPReverseProxy(option HTTPReverseProxyOptions, vhostRouter *Routers) * _, _ = rw.Write(getNotFoundPageContent()) }, } - rp.proxy = proxy + rp.proxy = h2c.NewHandler(proxy, &http2.Server{}) return rp }