config: add VhostEnableH2C flag to support HTTP/2 cleartext upgrade

This commit is contained in:
sword-jin
2024-11-28 02:40:12 +00:00
parent 8593eff752
commit 0a70a6a2d9
7 changed files with 60 additions and 25 deletions

View File

@@ -70,6 +70,7 @@ type serverInfoResp struct {
Version string `json:"version"`
BindPort int `json:"bindPort"`
VhostHTTPPort int `json:"vhostHTTPPort"`
VhostEnableH2C bool `json:"vhostEnableH2C"`
VhostHTTPSPort int `json:"vhostHTTPSPort"`
TCPMuxHTTPConnectPort int `json:"tcpmuxHTTPConnectPort"`
KCPBindPort int `json:"kcpBindPort"`
@@ -111,6 +112,7 @@ func (svr *Service) apiServerInfo(w http.ResponseWriter, r *http.Request) {
BindPort: svr.cfg.BindPort,
VhostHTTPPort: svr.cfg.VhostHTTPPort,
VhostHTTPSPort: svr.cfg.VhostHTTPSPort,
VhostEnableH2C: svr.cfg.VhostEnableH2C,
TCPMuxHTTPConnectPort: svr.cfg.TCPMuxHTTPConnectPort,
KCPBindPort: svr.cfg.KCPBindPort,
QUICBindPort: svr.cfg.QUICBindPort,

View File

@@ -281,6 +281,7 @@ func NewService(cfg *v1.ServerConfig) (*Service, error) {
if cfg.VhostHTTPPort > 0 {
rp := vhost.NewHTTPReverseProxy(vhost.HTTPReverseProxyOptions{
ResponseHeaderTimeoutS: cfg.VhostHTTPTimeout,
EnableH2C: cfg.VhostEnableH2C,
}, svr.httpVhostRouter)
svr.rc.HTTPReverseProxy = rp