Merge pull request #5196 from Budibase/labday/nginx-error-page
Add static html error page to nginx for 502, 503, 504
This commit is contained in:
commit
8a44f582ff
|
@ -27,6 +27,7 @@ services:
|
|||
image: nginx:latest
|
||||
volumes:
|
||||
- ./.generated-nginx.dev.conf:/etc/nginx/nginx.conf
|
||||
- ./proxy/error.html:/usr/share/nginx/html/error.html
|
||||
ports:
|
||||
- "${MAIN_PORT}:10000"
|
||||
depends_on:
|
||||
|
|
|
@ -28,6 +28,12 @@ http {
|
|||
ignore_invalid_headers off;
|
||||
proxy_buffering off;
|
||||
|
||||
error_page 502 503 504 /error.html;
|
||||
location = /error.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
|
||||
location /db/ {
|
||||
proxy_pass http://couchdb-service:5984;
|
||||
rewrite ^/db/(.*)$ /$1 break;
|
||||
|
|
|
@ -56,6 +56,12 @@ http {
|
|||
set $csp_media "media-src 'self' https://js.intercomcdn.com";
|
||||
set $csp_worker "worker-src 'none'";
|
||||
|
||||
error_page 502 503 504 /error.html;
|
||||
location = /error.html {
|
||||
root /usr/share/nginx/html;
|
||||
internal;
|
||||
}
|
||||
|
||||
# Security Headers
|
||||
add_header X-Frame-Options SAMEORIGIN always;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
FROM nginx:latest
|
||||
COPY .generated-nginx.prod.conf /etc/nginx/nginx.conf
|
||||
COPY error.html /usr/share/nginx/html/error.html
|
|
@ -0,0 +1,175 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Budibase</title>
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
</head>
|
||||
|
||||
<script>
|
||||
function checkStatusButton() {
|
||||
if (window.location.href.includes("budibase.app")) {
|
||||
var button = document.getElementById("statusButton")
|
||||
button.removeAttribute("hidden")
|
||||
}
|
||||
}
|
||||
|
||||
function goToStatus() {
|
||||
window.location.href = "https://status.budibase.com";
|
||||
}
|
||||
function goHome() {
|
||||
window.location.href = window.location.origin;
|
||||
}
|
||||
function getStatus() {
|
||||
var http = new XMLHttpRequest()
|
||||
var url = window.location.href
|
||||
http.open('GET', url, true)
|
||||
http.send()
|
||||
http.onreadystatechange = (e) => {
|
||||
var status = http.status
|
||||
document.getElementById("status").innerHTML = status
|
||||
|
||||
var message
|
||||
if (status === 502) {
|
||||
message = "Bad gateway. Please try again later."
|
||||
} else if (status === 503) {
|
||||
message = "Service Unavailable. Please try again later."
|
||||
} else if (status === 504) {
|
||||
message = "Gateway timeout. Please try again later."
|
||||
} else {
|
||||
message = "Please try again later."
|
||||
}
|
||||
|
||||
document.getElementById("message").innerHTML = message
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
checkStatusButton()
|
||||
getStatus()
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
:root {
|
||||
--spectrum-global-color-gray-600: rgb(144,144,144);
|
||||
--spectrum-global-color-gray-900: rgb(255,255,255);
|
||||
--spectrum-global-color-gray-800: rgb(227,227,227);
|
||||
--spectrum-global-color-static-blue-600: rgb(20,115,230);
|
||||
--spectrum-global-color-static-blue-hover: rgb( 18, 103, 207);
|
||||
}
|
||||
|
||||
html, body {
|
||||
background-color: #1a1a1a;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: #e7e7e7;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
button {
|
||||
color: #e7e7e7;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
border: none;
|
||||
font-size: 15px;
|
||||
border-radius: 15px;
|
||||
padding: 8px 22px;
|
||||
}
|
||||
button:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.main {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: left;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
.info {
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.status {
|
||||
color: var(--spectrum-global-color-gray-600)
|
||||
}
|
||||
.title {
|
||||
font-weight: 400;
|
||||
color: var(--spectrum-global-color-gray-900)
|
||||
}
|
||||
.message {
|
||||
font-weight: 200;
|
||||
color: var(--spectrum-global-color-gray-800)
|
||||
}
|
||||
.buttons {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.homeButton {
|
||||
background-color: var(--spectrum-global-color-static-blue-600);
|
||||
}
|
||||
.homeButton:hover {
|
||||
background-color: var(--spectrum-global-color-static-blue-hover);
|
||||
}
|
||||
.statusButton {
|
||||
background-color: transparent;
|
||||
margin-left: 20px;
|
||||
border: none;
|
||||
}
|
||||
.hero {
|
||||
height: 160px;
|
||||
width: 160px;
|
||||
margin-right: 80px;
|
||||
}
|
||||
.content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 600px) {
|
||||
.content {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="">
|
||||
</script>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="content">
|
||||
<div class="hero">
|
||||
<img src="https://raw.githubusercontent.com/Budibase/budibase/master/packages/builder/assets/bb-space-man.svg" alt="Budibase Logo">
|
||||
</div>
|
||||
<div class="info">
|
||||
<div>
|
||||
<h4 id="status" class="status"></h4>
|
||||
<h1 class="title">
|
||||
Houston we have a problem!
|
||||
</h1>
|
||||
<h3 id="message" class="message">
|
||||
</h3>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button class="homeButton" onclick=goHome()>Return home</button>
|
||||
<button id="statusButton" class="statusButton" hidden="true" onclick=goToStatus()>Check out status</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue