Skip to content

Commit 1be275b

Browse files
committed
Add primary access url
1 parent 21a269e commit 1be275b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

enterprise/cli/workspaceproxy.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"net"
1111
"net/http"
1212
"net/http/pprof"
13-
"net/url"
1413
"os/signal"
1514
"regexp"
1615
rpprof "runtime/pprof"
@@ -107,6 +106,7 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
107106
YAML: "externalWorkspaceProxy",
108107
}
109108
proxySessionToken clibase.String
109+
primaryAccessURL clibase.URL
110110
)
111111
opts.Add(
112112
// Options only for external workspace proxies
@@ -122,6 +122,18 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
122122
Group: &externalProxyOptionGroup,
123123
Hidden: false,
124124
},
125+
126+
clibase.Option{
127+
Name: "Coderd (Primary) Access URL",
128+
Description: "URL to communicate with coderd. This should match the access URL of the Coder deployment.",
129+
Flag: "primary-access-url",
130+
Env: "CODER_PRIMARY_ACCESS_URL",
131+
YAML: "primaryAccessURL",
132+
Default: "",
133+
Value: &primaryAccessURL,
134+
Group: &externalProxyOptionGroup,
135+
Hidden: false,
136+
},
125137
)
126138

127139
client := new(codersdk.Client)
@@ -137,6 +149,10 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
137149
r.InitClient(client),
138150
),
139151
Handler: func(inv *clibase.Invocation) error {
152+
if !(primaryAccessURL.Scheme == "http" || primaryAccessURL.Scheme == "https") {
153+
return xerrors.Errorf("primary access URL must be http or https: url=%s", primaryAccessURL)
154+
}
155+
140156
var closers closers
141157
// Main command context for managing cancellation of running
142158
// services.
@@ -255,11 +271,10 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
255271
closers.Add(closeFunc)
256272
}
257273

258-
pu, _ := url.Parse("http://localhost:3000")
259274
proxy, err := wsproxy.New(&wsproxy.Options{
260275
Logger: logger,
261276
// TODO: PrimaryAccessURL
262-
PrimaryAccessURL: pu,
277+
PrimaryAccessURL: primaryAccessURL.Value(),
263278
AccessURL: cfg.AccessURL.Value(),
264279
AppHostname: appHostname,
265280
AppHostnameRegex: appHostnameRegex,

0 commit comments

Comments
 (0)