Add startup and error pages

This commit is contained in:
Matthew Wild 2021-01-29 16:20:55 +00:00
parent 5eb4301064
commit d43c6ee266
11 changed files with 163 additions and 103 deletions

View File

@ -16,9 +16,13 @@ RUN apt-get update \
&& rm -rf /var/cache/*
ADD entrypoint.sh /entrypoint.sh
ADD render-template.sh /usr/local/bin/render-template.sh
ADD nginx/nginx.conf /etc/nginx/nginx.conf
ADD nginx/snikket-common.template /etc/nginx/templates/snikket-common
ADD nginx/http.template /etc/nginx/templates/http
ADD nginx/https.template /etc/nginx/templates/https
ADD supervisord.conf /etc/supervisord/supervisord.conf
ADD cert-monitor.sh /usr/local/bin/cert-monitor.sh
ADD static /var/www/html/static
ADD startup.html /var/www/html/index.html
ADD error-pages /var/www/html/_errors

View File

@ -2,17 +2,11 @@
CERT_PATH="/snikket/letsencrypt/live/$SNIKKET_DOMAIN/cert.pem"
export SNIKKET_TWEAK_HTTP_PORT=${SNIKKET_TWEAK_HTTP_PORT-80}
export SNIKKET_TWEAK_HTTPS_PORT=${SNIKKET_TWEAK_HTTPS_PORT-443}
export SNIKKET_TWEAK_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_INTERNAL_HTTP_PORT-5280}
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-5765}
while sleep 10; do
if test -f "$CERT_PATH"; then
/usr/local/bin/render-template.sh "/etc/nginx/templates/snikket-common" "/etc/nginx/snippets/snikket-common.conf"
for proto in http https; do
envsubst '$SNIKKET_DOMAIN $SNIKKET_TWEAK_HTTP_PORT $SNIKKET_TWEAK_HTTPS_PORT $SNIKKET_TWEAK_INTERNAL_HTTP_PORT $SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT' \
< /etc/nginx/templates/$proto \
> /etc/nginx/sites-enabled/$proto;
/usr/local/bin/render-template.sh "/etc/nginx/templates/$proto" "/etc/nginx/sites-enabled/$proto";
done
/usr/sbin/nginx -s reload
exit 0;

View File

@ -2,17 +2,11 @@
CERT_PATH="/snikket/letsencrypt/live/$SNIKKET_DOMAIN/cert.pem"
export SNIKKET_TWEAK_HTTP_PORT=${SNIKKET_TWEAK_HTTP_PORT-80}
export SNIKKET_TWEAK_HTTPS_PORT=${SNIKKET_TWEAK_HTTPS_PORT-443}
export SNIKKET_TWEAK_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_INTERNAL_HTTP_PORT-5280}
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-5765}
if test -f "$CERT_PATH"; then
## Certs already exist - render and deploy configs
/usr/local/bin/render-template.sh "/etc/nginx/templates/snikket-common" "/etc/nginx/snippets/snikket-common.conf"
for proto in http https; do
envsubst '$SNIKKET_DOMAIN $SNIKKET_TWEAK_HTTP_PORT $SNIKKET_TWEAK_HTTPS_PORT $SNIKKET_TWEAK_INTERNAL_HTTP_PORT $SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT' \
< /etc/nginx/templates/$proto \
> /etc/nginx/sites-enabled/$proto;
/usr/local/bin/render-template.sh "/etc/nginx/templates/$proto" "/etc/nginx/sites-enabled/$proto";
done
fi

30
error-pages/502.html Normal file
View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta charset="utf-8">
<title>Snikket | Temporarily unavailable</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/css/snikket.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#fbd308">
<meta name="theme-color" content="#fbd308">
</head>
<body style="background-color: #eee">
<div style="width: 80%; margin-top: 10%; margin-left: auto; margin-right: auto; background-color: #f8f8f8; padding: 3em;">
<img src="/static/img/snikket-logo-text.svg" alt="Snikket" style="width: 60%">
<h1>Oops! A technical glitch.</h1>
<p>There was a problem connecting to the Snikket service of this site.</p>
<p>If you just started this service, please wait a moment and reload the page.</p>
<p>If the problem continues, please check your Snikket configuration for problems.</p>
<code>502 Bad Gateway</code>
</div>
</body>
</html>

30
error-pages/503.html Normal file
View File

@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta charset="utf-8">
<title>Snikket | Temporarily unavailable</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/css/snikket.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#fbd308">
<meta name="theme-color" content="#fbd308">
</head>
<body style="background-color: #eee">
<div style="width: 80%; margin-top: 10%; margin-left: auto; margin-right: auto; background-color: #f8f8f8; padding: 3em;">
<img src="/static/img/snikket-logo-text.svg" alt="Snikket" style="width: 60%">
<h1>Oops! A technical glitch.</h1>
<p>There was a problem connecting to the Snikket service of this site.</p>
<p>If you just started this service, please wait a moment and reload the page.</p>
<p>If the problem continues, please check your Snikket configuration for problems.</p>
<code>503 Service Unavailable</code>
</div>
</body>
</html>

View File

@ -5,49 +5,7 @@ server {
server_name ${SNIKKET_DOMAIN};
server_name groups.${SNIKKET_DOMAIN};
root /var/www/html;
location / {
try_files $uri /static/$uri @portal;
}
location /admin_api {
try_files none @prosody;
}
location /invites_api {
try_files none @prosody;
}
location /oauth2 {
try_files none @prosody;
}
location /rest {
try_files none @prosody;
}
location /share {
alias /usr/share/javascript;
}
location /upload {
try_files none @prosody;
}
location @portal {
proxy_pass http://localhost:${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location @prosody {
proxy_pass http://localhost:${SNIKKET_TWEAK_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
include "/etc/nginx/snippets/snikket-common.conf";
}
server {

View File

@ -14,49 +14,7 @@ server {
server_name ${SNIKKET_DOMAIN};
server_name groups.${SNIKKET_DOMAIN};
root /var/www/html;
location / {
try_files $uri /static/$uri @portal;
}
location /admin_api {
try_files none @prosody;
}
location /invites_api {
try_files none @prosody;
}
location /oauth2 {
try_files none @prosody;
}
location /rest {
try_files none @prosody;
}
location /share {
alias /usr/share/javascript;
}
location /upload {
try_files none @prosody;
}
location @portal {
proxy_pass http://localhost:${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location @prosody {
proxy_pass http://localhost:${SNIKKET_TWEAK_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
include "/etc/nginx/snippets/snikket-common.conf";
}
server {

View File

@ -0,0 +1,47 @@
root /var/www/html;
location / {
try_files $uri /static/$uri @portal;
}
location /admin_api {
try_files none @prosody;
}
location /invites_api {
try_files none @prosody;
}
location /oauth2 {
try_files none @prosody;
}
location /rest {
try_files none @prosody;
}
location /share {
alias /usr/share/javascript;
}
location /upload {
try_files none @prosody;
}
location @portal {
proxy_pass http://localhost:${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
location @prosody {
proxy_pass http://localhost:${SNIKKET_TWEAK_INTERNAL_HTTP_PORT};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
error_page 502 /_errors/502.html;
error_page 503 /_errors/503.html;
error_page 504 /_errors/504.html;

10
render-template.sh Normal file
View File

@ -0,0 +1,10 @@
#!/bin/bash
export SNIKKET_TWEAK_HTTP_PORT=${SNIKKET_TWEAK_HTTP_PORT-80}
export SNIKKET_TWEAK_HTTPS_PORT=${SNIKKET_TWEAK_HTTPS_PORT-443}
export SNIKKET_TWEAK_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_INTERNAL_HTTP_PORT-5280}
export SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT=${SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT-5765}
exec envsubst '$SNIKKET_DOMAIN $SNIKKET_TWEAK_HTTP_PORT $SNIKKET_TWEAK_HTTPS_PORT $SNIKKET_TWEAK_INTERNAL_HTTP_PORT $SNIKKET_TWEAK_PORTAL_INTERNAL_HTTP_PORT' \
< "$1" \
> "$2";

35
startup.html Normal file
View File

@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="en" xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<meta charset="utf-8">
<meta http-equiv="refresh" content="10">
<title>Snikket is starting</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/static/css/snikket.css">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#fbd308">
<meta name="theme-color" content="#fbd308">
</head>
<body style="background-color: #eee">
<div style="width: 80%; margin-top: 10%; margin-left: auto; margin-right: auto; background-color: #f8f8f8; padding: 3em;">
<img src="/static/img/snikket-logo-text.svg" alt="Snikket" style="width: 60%">
<h1>Snikket is starting</h1>
<p>We are currently obtaining SSL/TLS certificates to secure your Snikket service.</p>
<p>The login page should appear in a moment. If not, please reload the page.</p>
<br>
<p>If this page appears for more than a few minutes, there may be a problem. Check that
all components of Snikket are started properly, that your DNS is correct, and that port
80 is open.
</p>
</div>
</body>
</html>

View File

@ -3,7 +3,7 @@
display: block;
width: 100%;
height: 100%;
background: url(/background.jpg) no-repeat center center fixed;
background: url(/static/img/background.jpg) no-repeat center center fixed;
background-size: cover;
filter: blur(10px);
opacity: 0.5;