@@ -10,7 +10,6 @@ import (
10
10
"net"
11
11
"net/http"
12
12
"net/http/pprof"
13
- "net/url"
14
13
"os/signal"
15
14
"regexp"
16
15
rpprof "runtime/pprof"
@@ -107,6 +106,7 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
107
106
YAML : "externalWorkspaceProxy" ,
108
107
}
109
108
proxySessionToken clibase.String
109
+ primaryAccessURL clibase.URL
110
110
)
111
111
opts .Add (
112
112
// Options only for external workspace proxies
@@ -122,6 +122,18 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
122
122
Group : & externalProxyOptionGroup ,
123
123
Hidden : false ,
124
124
},
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
+ },
125
137
)
126
138
127
139
client := new (codersdk.Client )
@@ -137,6 +149,10 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
137
149
r .InitClient (client ),
138
150
),
139
151
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
+
140
156
var closers closers
141
157
// Main command context for managing cancellation of running
142
158
// services.
@@ -255,11 +271,10 @@ func (r *RootCmd) proxyServer() *clibase.Cmd {
255
271
closers .Add (closeFunc )
256
272
}
257
273
258
- pu , _ := url .Parse ("http://localhost:3000" )
259
274
proxy , err := wsproxy .New (& wsproxy.Options {
260
275
Logger : logger ,
261
276
// TODO: PrimaryAccessURL
262
- PrimaryAccessURL : pu ,
277
+ PrimaryAccessURL : primaryAccessURL . Value () ,
263
278
AccessURL : cfg .AccessURL .Value (),
264
279
AppHostname : appHostname ,
265
280
AppHostnameRegex : appHostnameRegex ,
0 commit comments