diff --git a/Caddyfile b/Caddyfile index 305dcba..e770af9 100644 --- a/Caddyfile +++ b/Caddyfile @@ -1,3 +1,27 @@ +# Components + +(application_logging) { + log { + level INFO + output stdout + output file /var/log/caddy/caddy_{args[0]}.log { + roll_size 100MiB + roll_keep 5 + roll_keep_for 100d + } + format json + } +} + +(reverse_proxy_host) { + reverse_proxy host.containers.internal:{args[0]} +} + +(application_base) { + import application_logging {args[0]} + import reverse_proxy_host {args[1]} +} + { log default { output stdout @@ -16,70 +40,20 @@ admin :2019 } -# Grafana +# Routes :53100 { - log { - level INFO - output stdout - output file /var/log/caddy/caddy_grafana.log { - roll_size 100MiB - roll_keep 5 - roll_keep_for 100d - } - format json - } - - reverse_proxy host.containers.internal:3100 + import application_base "grafana" 3100 } -# Forgejo (web) - :53000 { - log { - level INFO - output stdout - output file /var/log/caddy/caddy_forgejo.log { - roll_size 100MiB - roll_keep 5 - roll_keep_for 100d - } - format json - } - - reverse_proxy host.containers.internal:3000 + import application_base "forgejo" 3000 } -# Forgejo (ssh) - :52052 { - log { - level INFO - output stdout - output file /var/log/caddy/caddy_forgejo-ssh.log { - roll_size 100MiB - roll_keep 5 - roll_keep_for 100d - } - format json - } - - reverse_proxy host.containers.internal:2052 + import application_base "forgejo-ssh" 2052 } -# Forgejo (postgres exporter / Prometheus) - :53001 { - log { - level INFO - output stdout - output file /var/log/caddy/caddy_forgejo-pg-exporter.log { - roll_size 10MiB - roll_keep 5 - roll_keep_for 10d - } - format json - } - - reverse_proxy host.containers.internal:3001 + import application_base "forgejo-pg-exporter" 3001 }