Skip to content

Instantly share code, notes, and snippets.

@subnut
Created April 13, 2022 12:45
Show Gist options
  • Save subnut/0c4a4fd12497a5a19893b9b947091c3c to your computer and use it in GitHub Desktop.
Save subnut/0c4a4fd12497a5a19893b9b947091c3c to your computer and use it in GitHub Desktop.
Sample error generic handling HTML page for caddy webserver
(common) {
tls internal
encode gzip zstd
handle_errors {
rewrite * /error.html
templates
file_server
}
}
example.com {
import common
respond "HI THERE"
}
*.example.com {
import common
error 404
}
<!-- vim: set ts=4 sw=0: -->
<html>
<head>
<!--
There are a couple of variants
{{placeholder "http.error.status_code"}} - {{placeholder "http.error.status_text"}}
{{placeholder "http.error.status_text"}} - {{placeholder "http.request.host"}}
-->
<title>
{{placeholder "http.error.status_code"}} · {{placeholder "http.error.status_text"}}
</title>
<style>
#outer {
display: table;
width: 100%;
height: 80%;
text-align: center;
}
#inner {
display: table-cell;
vertical-align: middle;
font-family: 'sans serif';
}
#inner h1 {
font-size: 12em;
color: gray;
margin: 0;
}
#inner p {
font-size: 2em;
font-weight: lighter;
margin: 0;
}
@media (prefers-color-scheme: dark) {
#inner h1 { color: silver; }
body {
background: black;
color: grey;
}
}
</style>
</head>
<body>
<div id="outer">
<div id="inner">
<h1>{{placeholder "http.error.status_code"}}</h1>
<p>{{placeholder "http.error.status_text"}}</p>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment