caddy: fix indentation for static site
Fix by moving the inline HTML to a separate file and serve it using `file_server` directive.
This commit is contained in:
parent
da88afbb51
commit
ed60032f75
|
@ -1,4 +1,4 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, unstable, ... }:
|
||||||
let
|
let
|
||||||
cfg = config.profile.services.caddy;
|
cfg = config.profile.services.caddy;
|
||||||
inherit (lib) mkIf attrsets strings lists;
|
inherit (lib) mkIf attrsets strings lists;
|
||||||
|
@ -7,6 +7,7 @@ in
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = unstable.caddy;
|
||||||
};
|
};
|
||||||
|
|
||||||
services.caddy.globalConfig = /*caddy*/ ''
|
services.caddy.globalConfig = /*caddy*/ ''
|
||||||
|
@ -15,7 +16,8 @@ in
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.caddy.virtualHosts =
|
environment.etc."caddy/static/tigor.web.id/index.html" = {
|
||||||
|
text =
|
||||||
let
|
let
|
||||||
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
|
domains = attrsets.mapAttrsToList (name: _: strings.removePrefix "https://" name) config.services.caddy.virtualHosts;
|
||||||
sortedDomains = lists.sort (a: b: a < b) domains;
|
sortedDomains = lists.sort (a: b: a < b) domains;
|
||||||
|
@ -23,11 +25,13 @@ in
|
||||||
(domain: /*html*/ ''
|
(domain: /*html*/ ''
|
||||||
<div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle">
|
<div class="col-12 col-sm-6 col-md-4 col-lg-3 text-center align-middle">
|
||||||
<a href="https://${domain}">${domain}</a>
|
<a href="https://${domain}">${domain}</a>
|
||||||
</div>'')
|
</div>
|
||||||
|
'')
|
||||||
sortedDomains;
|
sortedDomains;
|
||||||
items = strings.concatStringsSep "\n" list;
|
items = strings.concatStringsSep "\n" list;
|
||||||
html = /*html*/
|
in
|
||||||
''<!DOCTYPE html>
|
/*html*/ ''
|
||||||
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Hosted Sites</title>
|
<title>Hosted Sites</title>
|
||||||
|
@ -43,8 +47,13 @@ in
|
||||||
${items}
|
${items}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>'';
|
</html>
|
||||||
in
|
'';
|
||||||
|
user = "caddy";
|
||||||
|
group = "caddy";
|
||||||
|
};
|
||||||
|
|
||||||
|
services.caddy.virtualHosts =
|
||||||
{
|
{
|
||||||
"router.tigor.web.id".extraConfig = ''
|
"router.tigor.web.id".extraConfig = ''
|
||||||
@denied not remote_ip private_ranges
|
@denied not remote_ip private_ranges
|
||||||
|
@ -55,17 +64,13 @@ in
|
||||||
'';
|
'';
|
||||||
"tigor.web.id".extraConfig =
|
"tigor.web.id".extraConfig =
|
||||||
''
|
''
|
||||||
header Content-Type text/html
|
root * /etc/caddy/static/tigor.web.id
|
||||||
respond <<EOF
|
file_server
|
||||||
${html}
|
|
||||||
EOF 200
|
|
||||||
'';
|
'';
|
||||||
"crowfx.web.id".extraConfig =
|
"crowfx.web.id".extraConfig =
|
||||||
''
|
''
|
||||||
header Content-Type text/html
|
root * /etc/caddy/static/tigor.web.id
|
||||||
respond <<EOF
|
file_server
|
||||||
${html}
|
|
||||||
EOF 200
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue