clean error when r86s is down

This commit is contained in:
catvayor 2024-06-27 13:14:42 +02:00
parent d1d1688016
commit f99c4ced22
3 changed files with 95 additions and 16 deletions

View file

@ -71,23 +71,61 @@
in
{
enable = true;
virtualHosts = builtins.mapAttrs (_: _: {
enableACME = true;
forceSSL = true;
acmeFallbackHost = kat-r86s;
acmeFallbackRecommendedProxySettings = true;
locations."/" = {
recommendedProxySettings = true;
proxyPass = "https://${kat-r86s}/";
extraConfig = ''
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
virtualHosts =
let
watcher-webroot = pkgs.runCommand "watcher" { } ''
mkdir -p $out/.kat-watcher/
ln -nsf ${./error} $out/.kat-watcher/error
'';
};
}) vhosts;
in
{
"watcher.katvayor.net" = {
enableACME = true;
forceSSL = true;
locations = {
"/.kat-watcher" = {
extraConfig = ''
internal;
error_page 404 =418 /.kat-watcher/error/418.html;
'';
root = watcher-webroot;
};
"/" = {
extraConfig = ''
return 418;
error_page 418 =418 /.kat-watcher/error/418.html;
'';
};
};
};
}
// builtins.mapAttrs (_: _: {
enableACME = true;
forceSSL = true;
acmeFallbackHost = kat-r86s;
acmeFallbackRecommendedProxySettings = true;
locations = {
"/.kat-watcher" = {
extraConfig = ''
internal;
error_page 404 =418 /.kat-watcher/error/418.html;
'';
root = watcher-webroot;
};
"/" = {
recommendedProxySettings = true;
proxyPass = "https://${kat-r86s}/";
extraConfig = ''
proxy_set_header Connection ''';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
error_page 502 =599 "/.kat-watcher/error/599.html";
'';
};
};
}) vhosts;
streamConfig =
builtins.concatStringsSep "\n" (
lib.mapAttrsToList (

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<title>418 Im a teapot</title>
</head>
<body align="center">
<div role="main" align="center">
<h1>418 Im a teapot</h1>
<img src="https://http.cat/418.jpg"/>
<hr />
</div>
<div role="contentinfo" align="center">
<small>Crédit à <a href="https://http.cat">http.cat</a> pour l'image.</small>
<br/>
<small>Error in watcher.</small>
</div>
</body>
</html>

View file

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="color-scheme" content="light dark">
<title>599 Network Connect Timeout Error</title>
</head>
<body align="center">
<div role="main" align="center">
<h1>599 Network Connect Timeout Error</h1>
<img src="https://http.cat/599.jpg"/>
<p>Le contact avec l'hyperviseur n'a pas pu se faire.</p>
<hr />
</div>
<div role="contentinfo" align="center">
<small>Crédit à <a href="https://http.cat">http.cat</a> pour l'image.</small>
<br/>
<small>Error in watcher.</small>
</div>
</body>
</html>