diff --git a/conf/frpc_full.ini b/conf/frpc_full.ini index 71513eea..c84e684c 100644 --- a/conf/frpc_full.ini +++ b/conf/frpc_full.ini @@ -198,6 +198,7 @@ plugin_local_addr = 127.0.0.1:80 plugin_crt_path = ./server.crt plugin_key_path = ./server.key plugin_host_header_rewrite = 127.0.0.1 +plugin_header_X-From-Where = frp [secret_tcp] # If the type is secret tcp, remote_port is useless diff --git a/models/plugin/https2http.go b/models/plugin/https2http.go index 6e84ad62..ee561c19 100644 --- a/models/plugin/https2http.go +++ b/models/plugin/https2http.go @@ -35,6 +35,7 @@ type HTTPS2HTTPPlugin struct { keyPath string hostHeaderRewrite string localAddr string + headers map[string]string l *Listener s *http.Server @@ -45,6 +46,7 @@ func NewHTTPS2HTTPPlugin(params map[string]string) (Plugin, error) { keyPath := params["plugin_key_path"] localAddr := params["plugin_local_addr"] hostHeaderRewrite := params["plugin_host_header_rewrite"] + headerFromWhere := params["plugin_header_X-From-Where"] if crtPath == "" { return nil, fmt.Errorf("plugin_crt_path is required") @@ -63,7 +65,10 @@ func NewHTTPS2HTTPPlugin(params map[string]string) (Plugin, error) { keyPath: keyPath, localAddr: localAddr, hostHeaderRewrite: hostHeaderRewrite, - l: listener, + headers: map[string]string{ + "X-From-Where": headerFromWhere, + }, + l: listener, } rp := &httputil.ReverseProxy{ @@ -73,6 +78,9 @@ func NewHTTPS2HTTPPlugin(params map[string]string) (Plugin, error) { if p.hostHeaderRewrite != "" { req.Host = p.hostHeaderRewrite } + for k, v := range p.headers { + req.Header.Add(k, v) + } }, }