@@ -79,35 +79,34 @@ public static bool CreateServiceLabels(bool debug = false)
7979 if ( WorkspacesConfig . Workspaces . Count > 0 )
8080 {
8181 var traefikLabels = new Dictionary < string , string > ( ) ;
82+ var hosts = new List < string > ( ) ;
8283
8384 foreach ( KeyValuePair < string , WorkspaceEntryConfiguration > workspace in WorkspacesConfig . Workspaces )
8485 {
8586 if ( workspace . Value . Mode != WorkspaceMode . Vhost || workspace . Value . DisableWeb ) continue ;
8687
88+ traefikLabels . Add ( $ "traefik.enable", "true" ) ;
89+
8790 if ( workspace . Key == "main" )
8891 {
89- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-main.rule", $ "Host(`{ globalSubDomain } .{ domain } `)") ;
90- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-main.entrypoints", "https" ) ;
91- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-main.tls", "true" ) ;
92- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-main.service", $ "devcontainer@docker") ;
93- traefikLabels . Add ( $ "traefik.http.services.devcontainer-main.loadbalancer.server.port", "8080" ) ;
94-
95- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-www-main.rule", $ "Host(`www.{ globalSubDomain } .{ domain } `)") ;
96- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-www-main.entrypoints", "https" ) ;
97- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-www-main.tls", "true" ) ;
98- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-www-main.service", $ "devcontainer@docker") ;
99- traefikLabels . Add ( $ "traefik.http.services.devcontainer-www-main.loadbalancer.server.port", "8080" ) ;
92+ hosts . Add ( $ "Host(`{ globalSubDomain } .{ domain } `)") ;
93+ hosts . Add ( $ "Host(`www.{ globalSubDomain } .{ domain } `)") ;
10094 }
10195 else
10296 {
103- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-{ workspace . Value . SubDomain } .rule", $ "Host(`{ workspace . Value . SubDomain } .{ globalSubDomain } .{ domain } `)") ;
104- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-{ workspace . Value . SubDomain } .entrypoints", "https" ) ;
105- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-{ workspace . Value . SubDomain } .tls", "true" ) ;
106- traefikLabels . Add ( $ "traefik.http.routers.devcontainer-{ workspace . Value . SubDomain } .service", $ "devcontainer@docker") ;
107- traefikLabels . Add ( $ "traefik.http.services.devcontainer-{ workspace . Value . SubDomain } .loadbalancer.server.port", "8080" ) ;
97+ hosts . Add ( $ "Host(`{ workspace . Value . SubDomain } .{ globalSubDomain } .{ domain } `)") ;
10898 }
10999 }
110100
101+ if ( hosts . Count > 0 )
102+ {
103+ traefikLabels . Add ( $ "traefik.http.routers.devcontainer.rule", string . Join ( " || " , hosts ) ) ;
104+ traefikLabels . Add ( $ "traefik.http.routers.devcontainer.entrypoints", "https" ) ;
105+ traefikLabels . Add ( $ "traefik.http.routers.devcontainer.tls", "true" ) ;
106+ traefikLabels . Add ( $ "traefik.http.routers.devcontainer.service", $ "devcontainer@docker") ;
107+ traefikLabels . Add ( $ "traefik.http.services.devcontainer.loadbalancer.server.port", "8080" ) ;
108+ }
109+
111110 newServices [ "devcontainer" ] = new Dictionary < string , object > { { "labels" , traefikLabels } } ;
112111 }
113112
0 commit comments