- Notifications
You must be signed in to change notification settings - Fork928
feat: support wildcard apps over tunnel#4602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -207,15 +207,25 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code | ||
) | ||
defer closeTunnel() | ||
// If the access URL is empty, we attempt to run a reverse-proxy | ||
//tunnelto make the initial setup really simple. | ||
if dflags.AccessURL.Value == "" { | ||
cmd.Printf("Opening tunnel so workspaces can connect to your deployment. For production scenarios, specify an external access URL\n") | ||
tunnel, tunnelErr, err = devtunnel.New(ctxTunnel, logger.Named("devtunnel")) | ||
if err != nil { | ||
return xerrors.Errorf("create tunnel: %w", err) | ||
} | ||
dflags.AccessURL.Value = tunnel.URL | ||
if dflags.WildcardAccessURL.Value == "" { | ||
u, err := parseURL(ctx, tunnel.URL) | ||
if err != nil { | ||
return xerrors.Errorf("parse tunnel url: %w", err) | ||
} | ||
// Suffixed wildcard access URL. | ||
dflags.WildcardAccessURL.Value = fmt.Sprintf("*--%s", u.Hostname()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Shouldn't this just be one hypen? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. acutaly looks like ti deosnt matter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yeah it doesn't matter on the server side how many hyphens you use, but I used two here so it matches the two hyphens between each app component | ||
} | ||
} | ||
accessURLParsed, err := parseURL(ctx, dflags.AccessURL.Value) | ||
@@ -735,7 +745,7 @@ func Server(dflags *codersdk.DeploymentFlags, newAPI func(context.Context, *code | ||
// parseURL parses a string into a URL. It works around some technically correct | ||
// but undesired behavior of url.Parse by prepending a scheme if one does not | ||
// exist so that the URL does not get parsedimproperly. | ||
func parseURL(ctx context.Context, u string) (*url.URL, error) { | ||
var ( | ||
hasScheme = strings.HasPrefix(u, "http:") || strings.HasPrefix(u, "https:") | ||
@@ -1091,7 +1101,9 @@ func serveHandler(ctx context.Context, logger slog.Logger, handler http.Handler, | ||
} | ||
}() | ||
return func() { | ||
_ = srv.Close() | ||
} | ||
} | ||
// embeddedPostgresURL returns the URL for the embedded PostgreSQL deployment. | ||