mirror of
https://github.com/caprover/caprover
synced 2026-08-25 17:06:35 +00:00
Customized 502 error page
This commit is contained in:
@@ -461,6 +461,7 @@ class AppsDataStore {
|
||||
localDomain: localDomain,
|
||||
nginxConfigTemplate: nginxConfigTemplate,
|
||||
staticWebRoot: '',
|
||||
customErrorPagesDirectory: '',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -78,6 +78,9 @@ class LoadBalancerManager {
|
||||
CaptainConstants.nginxDomainSpecificHtmlDir +
|
||||
'/' +
|
||||
s.publicDomain;
|
||||
s.customErrorPagesDirectory =
|
||||
CaptainConstants.nginxStaticRootDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir;
|
||||
promises.push(Promise.resolve()
|
||||
.then(function () {
|
||||
return ejs.render(s.nginxConfigTemplate, {
|
||||
@@ -291,7 +294,10 @@ class LoadBalancerManager {
|
||||
CaptainConstants.captainConfirmationPath, self.getCaptainPublicRandomKey())
|
||||
.then(function () {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message: 'Nothing here yet :/',
|
||||
message_title: 'Nothing here yet :/',
|
||||
message_body: '',
|
||||
message_link: 'https://captainduckduck.com/',
|
||||
message_link_title: 'Read Docs',
|
||||
});
|
||||
})
|
||||
.then(function (staticPageContent) {
|
||||
@@ -301,13 +307,29 @@ class LoadBalancerManager {
|
||||
})
|
||||
.then(function () {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message: 'An Error Occurred :/',
|
||||
message_title: 'An Error Occurred :/',
|
||||
message_body: '',
|
||||
message_link: 'https://captainduckduck.com/',
|
||||
message_link_title: 'Read Docs',
|
||||
});
|
||||
})
|
||||
.then(function (errorPageContent) {
|
||||
.then(function (errorGenericPageContent) {
|
||||
return fs.outputFile(CaptainConstants.captainStaticFilesDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir +
|
||||
'/error.html', errorPageContent);
|
||||
'/error_generic_catch_all.html', errorGenericPageContent);
|
||||
})
|
||||
.then(function () {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message_title: 'NGINX 502 Error :/',
|
||||
message_body: "If you are the developer, check your application's logs. See the link below for details",
|
||||
message_link: 'https://captainduckduck.com/docs/troubleshooting.html#successful-deploy-but-502-bad-gateway-error',
|
||||
message_link_title: 'Docs - 502 Troubleshooting',
|
||||
});
|
||||
})
|
||||
.then(function (error502PageContent) {
|
||||
return fs.outputFile(CaptainConstants.captainStaticFilesDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir +
|
||||
'/captain_502_custom_error_page.html', error502PageContent);
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d('Setting up NGINX conf file...');
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -652,6 +652,7 @@ class AppsDataStore {
|
||||
localDomain: localDomain,
|
||||
nginxConfigTemplate: nginxConfigTemplate,
|
||||
staticWebRoot: '',
|
||||
customErrorPagesDirectory: '',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ interface IServerBlockDetails {
|
||||
|
||||
crtPath?: string
|
||||
keyPath?: string
|
||||
|
||||
customErrorPagesDirectory: string
|
||||
staticWebRoot: string
|
||||
}
|
||||
|
||||
@@ -109,6 +109,10 @@ class LoadBalancerManager {
|
||||
'/' +
|
||||
s.publicDomain
|
||||
|
||||
s.customErrorPagesDirectory =
|
||||
CaptainConstants.nginxStaticRootDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir
|
||||
|
||||
promises.push(
|
||||
Promise.resolve()
|
||||
.then(function() {
|
||||
@@ -392,7 +396,10 @@ class LoadBalancerManager {
|
||||
)
|
||||
.then(function() {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message: 'Nothing here yet :/',
|
||||
message_title: 'Nothing here yet :/',
|
||||
message_body: '',
|
||||
message_link: 'https://captainduckduck.com/',
|
||||
message_link_title: 'Read Docs',
|
||||
})
|
||||
})
|
||||
.then(function(staticPageContent) {
|
||||
@@ -405,15 +412,36 @@ class LoadBalancerManager {
|
||||
})
|
||||
.then(function() {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message: 'An Error Occurred :/',
|
||||
message_title: 'An Error Occurred :/',
|
||||
message_body: '',
|
||||
message_link: 'https://captainduckduck.com/',
|
||||
message_link_title: 'Read Docs',
|
||||
})
|
||||
})
|
||||
.then(function(errorPageContent) {
|
||||
.then(function(errorGenericPageContent) {
|
||||
return fs.outputFile(
|
||||
CaptainConstants.captainStaticFilesDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir +
|
||||
'/error.html',
|
||||
errorPageContent
|
||||
'/error_generic_catch_all.html',
|
||||
errorGenericPageContent
|
||||
)
|
||||
})
|
||||
.then(function() {
|
||||
return ejs.render(defaultPageTemplate, {
|
||||
message_title: 'NGINX 502 Error :/',
|
||||
message_body:
|
||||
"If you are the developer, check your application's logs. See the link below for details",
|
||||
message_link:
|
||||
'https://captainduckduck.com/docs/troubleshooting.html#successful-deploy-but-502-bad-gateway-error',
|
||||
message_link_title: 'Docs - 502 Troubleshooting',
|
||||
})
|
||||
})
|
||||
.then(function(error502PageContent) {
|
||||
return fs.outputFile(
|
||||
CaptainConstants.captainStaticFilesDir +
|
||||
CaptainConstants.nginxDefaultHtmlDir +
|
||||
'/captain_502_custom_error_page.html',
|
||||
error502PageContent
|
||||
)
|
||||
})
|
||||
.then(function() {
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding: 0px 20px;
|
||||
max-width: 450px;
|
||||
padding: 20px;
|
||||
max-width: 550px;
|
||||
}
|
||||
|
||||
.message__title {
|
||||
@@ -57,7 +57,12 @@
|
||||
background: linear-gradient(135deg, #1d5b85 0%, #3295c7 100%);
|
||||
}
|
||||
|
||||
body.defaultpagebody .message__title {
|
||||
.message__title {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.message {
|
||||
padding: 25px;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
@@ -73,14 +78,21 @@
|
||||
color: #fff;
|
||||
border: 2px solid rgba(255, 255, 255, 0.7);
|
||||
}
|
||||
|
||||
</style>
|
||||
<base target=_parent /> </head>
|
||||
<base target=_parent />
|
||||
</head>
|
||||
|
||||
<body class=defaultpagebody>
|
||||
<div class=spacer></div>
|
||||
<div class=message>
|
||||
<div class=message__title> <%=message%> </div> <a href="http://www.captainduckduck.com" class=btn>Visit Captain DuckDuck</a> </div>
|
||||
<div class=message>
|
||||
<div class=message__title>
|
||||
<%=message_title%>
|
||||
</div>
|
||||
<div class=message>
|
||||
<%=message_body%>
|
||||
</div>
|
||||
<a href="<%=message_link%>" target="_blank" rel="noopener noreferrer" class="btn">
|
||||
<%=message_link_title%></a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -2,7 +2,20 @@
|
||||
# Default catch-all page. e.g. if you enter SOME-RANDOM-CHARS.captainroot.domain.com
|
||||
server {
|
||||
|
||||
# Catch all HTTP
|
||||
listen 80;
|
||||
|
||||
# Catch all HTTPS
|
||||
<%
|
||||
if (captain.hasRootSsl) {
|
||||
%>
|
||||
listen 443 ssl;
|
||||
ssl_certificate <%-captain.crtPath%>;
|
||||
ssl_certificate_key <%-captain.keyPath%>;
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
||||
server_name _;
|
||||
|
||||
location /nginx_status {
|
||||
@@ -18,7 +31,8 @@
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
error_page 404 500 502 503 504 /error.html;
|
||||
error_page 404 /index.html;
|
||||
error_page 500 502 503 504 /error_generic_catch_all.html;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,12 @@ if (!s.forceSsl || s.hasSsl) {
|
||||
location /.well-known/ {
|
||||
root <%-s.staticWebRoot%>;
|
||||
}
|
||||
|
||||
error_page 502 /captain_502_custom_error_page.html;
|
||||
location = /captain_502_custom_error_page.html {
|
||||
root <%-s.customErrorPagesDirectory%>;
|
||||
internal;
|
||||
}
|
||||
}
|
||||
|
||||
<%
|
||||
|
||||
Reference in New Issue
Block a user