@@ -25,13 +25,22 @@ const main = async (args: Args): Promise<void> => {
25
25
logger . warn ( error . message )
26
26
}
27
27
28
+ /**
29
+ * Domains can be in the form `coder.com` or `*.coder.com`. Either way,
30
+ * `[number].coder.com` will be proxied to `number`.
31
+ */
32
+ const normalizeProxyDomains = ( domains ?: string [ ] ) : string [ ] => {
33
+ return domains ? domains . map ( ( d ) => d . replace ( / ^ \* \. / , "" ) ) . filter ( ( d , i ) => domains . indexOf ( d ) === i ) : [ ]
34
+ }
35
+
28
36
// Spawn the main HTTP server.
29
37
const options : HttpServerOptions = {
30
38
auth,
31
39
commit : commit || "development" ,
32
40
host : args . host || ( args . auth === AuthType . Password && typeof args . cert !== "undefined" ? "0.0.0.0" : "localhost" ) ,
33
41
password : originalPassword ? hash ( originalPassword ) : undefined ,
34
42
port : typeof args . port !== "undefined" ? args . port : process . env . PORT ? parseInt ( process . env . PORT , 10 ) : 8080 ,
43
+ proxyDomains : normalizeProxyDomains ( args [ "proxy-domain" ] ) ,
35
44
socket : args . socket ,
36
45
...( args . cert && ! args . cert . value
37
46
? await generateCertificate ( )
@@ -98,6 +107,15 @@ const main = async (args: Args): Promise<void> => {
98
107
logger . info ( " - Not serving HTTPS" )
99
108
}
100
109
110
+ if ( options . proxyDomains && options . proxyDomains . length === 1 ) {
111
+ logger . info ( ` - Proxying *.${ options . proxyDomains [ 0 ] } ` )
112
+ } else if ( options . proxyDomains && options . proxyDomains . length > 1 ) {
113
+ logger . info ( " - Proxying the following domains:" )
114
+ options . proxyDomains . forEach ( ( domain ) => {
115
+ logger . info ( ` - *.${ domain } ` )
116
+ } )
117
+ }
118
+
101
119
logger . info ( `Automatic updates are ${ update . enabled ? "enabled" : "disabled" } ` )
102
120
103
121
if ( sshPort ) {
0 commit comments