Skip to content

Commit 22b5e41

Browse files
committed
1 parent a71dfbc commit 22b5e41

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/models/IServerBlockDetails.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ interface IServerBlockDetails {
1313
keyPath?: string
1414
customErrorPagesDirectory: string
1515
staticWebRoot: string
16+
redirectToPath?: string
1617
}

src/user/system/LoadBalancerManager.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,14 @@ class LoadBalancerManager {
285285
nginxConfigTemplate
286286
serverWithSubDomain.httpBasicAuth = httpBasicAuth
287287

288+
if (
289+
webApp.redirectDomain &&
290+
serverWithSubDomain.publicDomain !==
291+
webApp.redirectDomain
292+
) {
293+
serverWithSubDomain.redirectToPath = `http://${webApp.redirectDomain}`
294+
}
295+
288296
servers.push(serverWithSubDomain)
289297

290298
// adding custom domains
@@ -296,7 +304,7 @@ class LoadBalancerManager {
296304
idx++
297305
) {
298306
const d = customDomainArray[idx]
299-
servers.push({
307+
const newServerBlock: IServerBlockDetails = {
300308
containerHttpPort: httpPort,
301309
hasSsl: d.hasSsl,
302310
forceSsl: forceSsl,
@@ -307,7 +315,15 @@ class LoadBalancerManager {
307315
staticWebRoot: '',
308316
customErrorPagesDirectory: '',
309317
httpBasicAuth: httpBasicAuth,
310-
})
318+
}
319+
if (
320+
webApp.redirectDomain &&
321+
newServerBlock.publicDomain !==
322+
webApp.redirectDomain
323+
) {
324+
newServerBlock.redirectToPath = `http://${webApp.redirectDomain}`
325+
}
326+
servers.push(newServerBlock)
311327
}
312328
}
313329
})

template/server-block-conf.ejs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,18 @@ server {
5757

5858
location / {
5959

60+
61+
<%
62+
if (s.redirectToPath) {
63+
%>
64+
return 302 <%-s.redirectToPath%>
65+
<%
66+
}
67+
%>
68+
69+
70+
71+
6072
<%
6173
if (s.httpBasicAuthPath) {
6274
%>

0 commit comments

Comments
 (0)