grace/dots

dotfiles/nix configs

git clone https://git.gae.moe/grace/dots

Grace Yoderi gotta stop doing these massive changesb70d9f9

main
1002 B35 linesraw
1{ lib, pkgs, ... }:
2
3let
4  # TODO: make an actual offline page.
5  offlinePage = pkgs.writeTextDir "offline.html" ''
6    <!doctype html>
7    <html lang="en"><head><title>Service temporarily offline</title></head>
8    <body><h1>Page Down</h1><p>The backend server is offline. Please check again later.</p></body></html>
9  '';
10in
11{
12  options.services.nginx.virtualHosts = lib.mkOption {
13    type = lib.types.attrsOf (
14      lib.types.submodule {
15        config = {
16          enableACME = lib.mkDefault true;
17          forceSSL = lib.mkDefault true;
18          extraConfig = ''
19            error_page 502 503 504 /_offline.html;
20            proxy_intercept_errors on;
21          '';
22          locations."= /_offline.html" = {
23            root = offlinePage;
24            extraConfig = ''
25              internal;
26              auth_request off;
27              rewrite ^ /offline.html break;
28              add_header Cache-Control "no-store" always;
29            '';
30          };
31        };
32      }
33    );
34  };
35}