@@ -57,7 +57,8 @@ func (p *proxyServer) Start() error {
5757 p .proxy .Use (
5858 func (next echo.HandlerFunc ) echo.HandlerFunc {
5959 return func (c echo.Context ) error {
60- if strings .HasSuffix (c .Request ().Host , ".olares.local" ) {
60+ if strings .HasSuffix (c .Request ().Host , ".olares.local" ) ||
61+ strings .HasSuffix (c .Request ().Host , "-olares.local" ) {
6162 if c .IsWebSocket () {
6263 ctx := c .Request ().Context ()
6364 ctx = context .WithValue (ctx , WSKey , true )
@@ -103,7 +104,25 @@ func (p *proxyServer) Next(c echo.Context) *middleware.ProxyTarget {
103104 if c .IsWebSocket () {
104105 scheme = "wss://"
105106 }
106- proxyPass , err := url .Parse (scheme + c .Request ().Host + ":443" )
107+
108+ var (
109+ proxyPass * url.URL
110+ err error
111+ )
112+ requestHost := c .Request ().Host
113+ if strings .HasSuffix (requestHost , "-olares.local" ) {
114+ // intranet request, and host parttern is appid-<username>-olares.local for windows and linux client
115+ tokens := strings .Split (requestHost , "-" )
116+ if len (tokens ) < 3 {
117+ klog .Error ("invalid intranet request host, " , requestHost )
118+ return nil
119+ }
120+ requestHost = strings .Join (tokens , "." )
121+ c .Request ().Host = requestHost
122+ proxyPass , err = url .Parse (scheme + requestHost + ":443" )
123+ } else {
124+ proxyPass , err = url .Parse (scheme + c .Request ().Host + ":443" )
125+ }
107126 if err != nil {
108127 klog .Error ("parse proxy target error, " , err )
109128 return nil
0 commit comments