Update caddy
This commit is contained in:
parent
4fc067bf21
commit
497ab9a82a
1 changed files with 41 additions and 20 deletions
|
|
@ -1,23 +1,44 @@
|
||||||
{ config, pkgs, inputs, lib, ... }:
|
{ config, pkgs, inputs, lib, ... }:
|
||||||
|
let
|
||||||
|
# String = simple site, Attrset = custom site.
|
||||||
|
sites = {
|
||||||
|
"analytics.figtree.dev" = "http://192.168.80.1:3300";
|
||||||
|
"figtree.dev" = "http://192.168.1.63:8080";
|
||||||
|
"files.figtree.dev" = "http://192.168.80.4:8080";
|
||||||
|
"git.figtree.dev" = "http://192.168.80.2:3000";
|
||||||
|
"nc.figtree.dev" = "http://192.168.1.62:11000";
|
||||||
|
"paperless.figtree.dev" = "http://192.168.1.63:8010";
|
||||||
|
"photos.figtree.dev" = "http://192.168.80.1:2283";
|
||||||
|
"shiori.figtree.dev" = "http://192.168.80.4:8234";
|
||||||
|
"tasks.figtree.dev" = "http://192.168.80.7:3456";
|
||||||
|
"www.figtree.dev" = "http://192.168.1.63:8080";
|
||||||
|
"ha.figtree.dev" = "http://192.168.1.50:8123";
|
||||||
|
# "budget.figtree.dev" = "http://192.168.80.1:5006";
|
||||||
|
|
||||||
|
# Only this one needs extra top-level Caddyfile lines:
|
||||||
|
"budget.box" = {
|
||||||
|
backend = "http://192.168.80.1:5006";
|
||||||
|
extraBefore = ''
|
||||||
|
tls internal
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Turn strings into { backend = "..."; }
|
||||||
|
normalizedSites = lib.mapAttrs (_: v: if lib.isString v then { backend = v; } else v) sites;
|
||||||
|
|
||||||
|
# Render each vhost
|
||||||
|
mkVHost = cfg: {
|
||||||
|
extraConfig = ''
|
||||||
|
${lib.optionalString (cfg ? extraBefore) cfg.extraBefore}
|
||||||
|
reverse_proxy ${cfg.backend}
|
||||||
|
${lib.optionalString (cfg ? extra) cfg.extra}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts = lib.mapAttrs'
|
virtualHosts = lib.mapAttrs (_domain: cfg: mkVHost cfg) normalizedSites;
|
||||||
(domain: backend: {
|
};
|
||||||
name = domain;
|
|
||||||
value.extraConfig = "reverse_proxy ${backend}";
|
|
||||||
})
|
|
||||||
{
|
|
||||||
"analytics.figtree.dev" = "http://192.168.80.1:3300";
|
|
||||||
"figtree.dev" = "http://192.168.1.63:8080";
|
|
||||||
"files.figtree.dev" = "http://192.168.80.4:8080";
|
|
||||||
"git.figtree.dev" = "http://192.168.80.2:3000";
|
|
||||||
"nc.figtree.dev" = "http://192.168.1.62:11000";
|
|
||||||
"paperless.figtree.dev" = "http://192.168.1.63:8010";
|
|
||||||
"photos.figtree.dev" = "http://192.168.80.1:2283";
|
|
||||||
"shiori.figtree.dev" = "http://192.168.80.4:8234";
|
|
||||||
"tasks.figtree.dev" = "http://192.168.80.7:3456";
|
|
||||||
"www.figtree.dev" = "http://192.168.1.63:8080";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue