use static html error page

This commit is contained in:
Karol Wypchlo 2022-05-20 12:37:41 +02:00
parent 185daf6a08
commit 35bf172d28
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
8 changed files with 96 additions and 8 deletions

View File

@ -74,9 +74,8 @@ services:
- ./docker/data/certbot:/etc/letsencrypt
- ./docker/nginx/libs:/etc/nginx/libs
- ./docker/nginx/conf.d:/etc/nginx/conf.d
- ./docker/nginx/conf.d.templates:/etc/nginx/templates
- ./docker/nginx/templates:/etc/nginx/templates
- ./docker/nginx/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./docker/data/website/public:/etc/nginx/public
networks:
shared:
ipv4_address: 10.10.10.30

View File

@ -38,12 +38,12 @@ proxy_set_header User-Agent: Sia-Agent;
proxy_pass http://sia:9980/skynet/skylink/$skylink$path$is_args$args;
proxy_intercept_errors on;
error_page 400 /etc/nginx/public/errors/400/index.html;
error_page 401 /etc/nginx/public/errors/401/index.html;
error_page 403 /etc/nginx/public/errors/403/index.html;
error_page 404 /etc/nginx/public/errors/404/index.html;
error_page 451 /etc/nginx/public/errors/451/index.html;
error_page 500 /etc/nginx/public/errors/500/index.html;
# error_page 400 /etc/nginx/public/etc/nginx/conf.d/pages/400.html;
error_page 401 /etc/nginx/public/etc/nginx/conf.d/pages/401.html;
# error_page 403 /etc/nginx/public/etc/nginx/conf.d/pages/403.html;
# error_page 404 /etc/nginx/public/etc/nginx/conf.d/pages/404.html;
# error_page 451 /etc/nginx/public/etc/nginx/conf.d/pages/451.html;
# error_page 500 501 502 503 /etc/nginx/public/etc/nginx/conf.d/pages/5xx.html;
log_by_lua_block {
local skynet_account = require("skynet.account")

View File

@ -0,0 +1,89 @@
<!DOCTYPE html>
<html class="h-full">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- meta tags generated with https://metatags.io/ -->
<title>401: Unauthorized</title>
<meta name="title" content="401: Unauthorized" />
<meta
name="description"
content="You must be authenticated to access this content"
/>
<!-- svg favicon encoded with https://yoksel.github.io/url-encoder/ -->
<link
rel="icon"
href="data:image/svg+xml, %3Csvg role='img' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg' fill='%2300C65E' %3E%3Ctitle%3ESkynet%3C/title%3E%3Cpath d='m-.0004 6.4602 21.3893 11.297c.561.2935.6633 1.0532.1999 1.4846h-.011a10.0399 10.0399 0 0 1-2.2335 1.5307c-6.912 3.4734-14.9917-1.838-14.5438-9.5605l2.8601 1.9752c.856 4.508 5.6187 7.1094 9.8742 5.3932zm8.6477 3.1509 14.3661 5.6785a.8704.8704 0 0 1 .5197 1.0466v.0182c-.1537.5377-.7668.7938-1.2575.5252zm5.2896-7.4375c2.7093-.2325 6.0946.7869 8.1116 3.3871 1.699 2.1951 2.0497 4.8772 1.9298 7.6465v-.007c-.0478.5874-.6494.9616-1.1975.745l-9.7652-3.8596 9.0656 2.4313a7.296 7.296 0 0 0-1.0677-4.5631c-2.9683-4.7678-9.9847-4.5344-12.6297.4201a7.5048 7.5048 0 0 0-.398.8831L5.5546 7.9614c.069-.1017.1417-.198.2144-.2962.1163-.2416.2417-.487.3798-.7268 1.6118-2.7911 4.3102-4.4338 7.1558-4.6973.2108-.0182.4215-.049.6323-.0672z' /%3E%3C/svg%3E"
type="image/svg+xml"
/>
<!-- https://fonts.google.com/specimen/Sora -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Sora:wght@400;800&display=swap"
rel="stylesheet"
/>
<!-- https://tailwindcss.com/docs/installation/play-cdn -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: { extend: { fontFamily: { sans: ["Sora", "sans-serif"] } } },
};
</script>
</head>
<body class="h-full">
<div
class="bg-white min-h-full px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8"
>
<div class="max-w-max mx-auto">
<main class="sm:flex">
<svg
role="img"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
height="88"
fill="#00C65E"
>
<title>Skynet</title>
<path
d="m-.0004 6.4602 21.3893 11.297c.561.2935.6633 1.0532.1999 1.4846h-.011a10.0399 10.0399 0 0 1-2.2335 1.5307c-6.912 3.4734-14.9917-1.838-14.5438-9.5605l2.8601 1.9752c.856 4.508 5.6187 7.1094 9.8742 5.3932zm8.6477 3.1509 14.3661 5.6785a.8704.8704 0 0 1 .5197 1.0466v.0182c-.1537.5377-.7668.7938-1.2575.5252zm5.2896-7.4375c2.7093-.2325 6.0946.7869 8.1116 3.3871 1.699 2.1951 2.0497 4.8772 1.9298 7.6465v-.007c-.0478.5874-.6494.9616-1.1975.745l-9.7652-3.8596 9.0656 2.4313a7.296 7.296 0 0 0-1.0677-4.5631c-2.9683-4.7678-9.9847-4.5344-12.6297.4201a7.5048 7.5048 0 0 0-.398.8831L5.5546 7.9614c.069-.1017.1417-.198.2144-.2962.1163-.2416.2417-.487.3798-.7268 1.6118-2.7911 4.3102-4.4338 7.1558-4.6973.2108-.0182.4215-.049.6323-.0672z"
/>
</svg>
<div class="sm:ml-6">
<div class="sm:border-l sm:border-gray-200 sm:pl-6">
<h1
class="text-xl font-extrabold text-gray-900 tracking-tight sm:text-2xl"
>
You must be authenticated to access this content
</h1>
<p class="mt-1 text-base text-gray-500">
You're being redirected to the Log In page of this Skynet Portal
</p>
<p class="mt-2 text-sm text-gray-300">HTTP 401: Unauthorized</p>
</div>
<div
class="mt-10 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6"
>
<p class="mt-1 text-sm text-gray-500">
If you're not redirected automatically,
<a
href="https://account.${PORTAL_DOMAIN}/auth/login"
class="text-[#00C65E]"
>click here</a
>.
</p>
</div>
</div>
</main>
</div>
</div>
<script>
// prevent auto redirect if not on portal domain to allow local development
if (window.location.hostname.endsWith("${PORTAL_DOMAIN}")) {
setTimeout(function redirect() {
window.location.href = "https://account.${PORTAL_DOMAIN}/auth/login";
}, 3000);
}
</script>
</body>
</html>