diff --git a/models/config/proxy.go b/models/config/proxy.go index dabcd65e..9bdd8341 100644 --- a/models/config/proxy.go +++ b/models/config/proxy.go @@ -580,8 +580,8 @@ func (cfg *TcpProxyConf) CheckForCli() (err error) { } func (cfg *TcpProxyConf) CheckForSvr(serverCfg ServerCommonConf) (err error) { - if len(cfg.CustomDomains) == 0 && cfg.SubDomain == "" && serverCfg.VhostTcpPort != 0 { - return fmt.Errorf("type [tcp] not support when vhost_http_port is on but no custom domain or subdomain configured") + if (len(cfg.CustomDomains) > 0 || cfg.SubDomain != "") && serverCfg.VhostTcpPort == 0 { + return fmt.Errorf("custom domain or subdomain can't be configured on type [tcp] without vhost_http_port") } return } diff --git a/server/proxy/tcp.go b/server/proxy/tcp.go index 4fadb0e0..b18ea4b6 100644 --- a/server/proxy/tcp.go +++ b/server/proxy/tcp.go @@ -46,7 +46,7 @@ func (pxy *TcpProxy) Run() (remoteAddr string, err error) { pxy.listeners = append(pxy.listeners, l) xl.Info("tcp proxy listen port [%d] in group [%s]", pxy.cfg.RemotePort, pxy.cfg.Group) } else { - if pxy.serverCfg.VhostTcpPort > 0 { + if pxy.serverCfg.VhostTcpPort > 0 && (len(pxy.cfg.CustomDomains) > 0 || pxy.cfg.SubDomain != "") { pxy.realPort = pxy.serverCfg.VhostTcpPort routeConfig := &vhost.VhostRouteConfig{} for _, domain := range pxy.cfg.CustomDomains {