Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit47cb9ab

Browse files
authored
feat: support wildcard apps over tunnel (#4602)
1 parent43d1f72 commit47cb9ab

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎cli/server.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,25 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
208208
)
209209
defercloseTunnel()
210210

211-
// If the access URL is empty, we attempt to run a reverse-proxy tunnel
212-
// to make the initial setup really simple.
211+
// If the access URL is empty, we attempt to run a reverse-proxy
212+
//tunnelto make the initial setup really simple.
213213
ifdflags.AccessURL.Value=="" {
214214
cmd.Printf("Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL\n")
215215
tunnel,tunnelErr,err=devtunnel.New(ctxTunnel,logger.Named("devtunnel"))
216216
iferr!=nil {
217217
returnxerrors.Errorf("create tunnel: %w",err)
218218
}
219219
dflags.AccessURL.Value=tunnel.URL
220+
221+
ifdflags.WildcardAccessURL.Value=="" {
222+
u,err:=parseURL(ctx,tunnel.URL)
223+
iferr!=nil {
224+
returnxerrors.Errorf("parse tunnel url: %w",err)
225+
}
226+
227+
// Suffixed wildcard access URL.
228+
dflags.WildcardAccessURL.Value=fmt.Sprintf("*--%s",u.Hostname())
229+
}
220230
}
221231

222232
accessURLParsed,err:=parseURL(ctx,dflags.AccessURL.Value)
@@ -752,7 +762,7 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code
752762

753763
// parseURL parses a string into a URL. It works around some technically correct
754764
// but undesired behavior of url.Parse by prepending a scheme if one does not
755-
// exist so that the URL does not get parsedimproprely.
765+
// exist so that the URL does not get parsedimproperly.
756766
funcparseURL(ctx context.Context,ustring) (*url.URL,error) {
757767
var (
758768
hasScheme=strings.HasPrefix(u,"http:")||strings.HasPrefix(u,"https:")
@@ -1108,7 +1118,9 @@ func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler,
11081118
}
11091119
}()
11101120

1111-
returnfunc() {_=srv.Close() }
1121+
returnfunc() {
1122+
_=srv.Close()
1123+
}
11121124
}
11131125

11141126
// embeddedPostgresURL returns the URL for the embedded PostgreSQL deployment.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp