all: reformat caddy logs

This commit is contained in:
Adithya 2024-09-14 19:36:59 +05:30
parent 4bb172fa9e
commit 29555fda8b
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
5 changed files with 59 additions and 24 deletions

View file

@ -1,13 +1,19 @@
_: { _:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
in
{
services = { services = {
caddy = { caddy = {
virtualHosts = { virtualHosts = {
"jellyfin.local.adtya.xyz" = { "jellyfin.local.adtya.xyz" = {
logFormat = logFormat "jellyfin.local.adtya.xyz";
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:8096 reverse_proxy 127.0.0.1:8096
''; '';
}; };
"jellyfin.labs.adtya.xyz" = { "jellyfin.labs.adtya.xyz" = {
logFormat = logFormat "jellyfin.labs.adtya.xyz";
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:8096 reverse_proxy 127.0.0.1:8096
''; '';

View file

@ -1,7 +1,12 @@
{ pkgs, ... }: { { pkgs, ... }:
let
inherit (import ../../../shared/caddy-helpers.nix) logFormat;
in
{
services = { services = {
caddy = { caddy = {
virtualHosts."transmission.labs.adtya.xyz" = { virtualHosts."transmission.labs.adtya.xyz" = {
logFormat = logFormat "transmission.labs.adtya.xyz";
extraConfig = '' extraConfig = ''
reverse_proxy 127.0.0.1:9091 reverse_proxy 127.0.0.1:9091
''; '';

View file

@ -0,0 +1,11 @@
{
logFormat = fileName: ''
output file /var/log/caddy/${fileName}.log {
roll_size 100MiB
roll_keep 5
roll_keep_for 100d
}
format json
level INFO
'';
}

View file

@ -1,4 +1,8 @@
{ config, inputs, pkgs, ... }: { { config, inputs, pkgs, ... }:
let
inherit (import ./caddy-helpers.nix) logFormat;
in
{
sops = { sops = {
secrets = { secrets = {
"caddy/env_file" = { "caddy/env_file" = {
@ -15,7 +19,7 @@
globalConfig = '' globalConfig = ''
acme_dns digitalocean {env.DO_API_TOKEN} acme_dns digitalocean {env.DO_API_TOKEN}
''; '';
logFormat = "level INFO"; logFormat = logFormat "caddy_main";
}; };
systemd.services.caddy.serviceConfig.EnvironmentFile = config.sops.secrets."caddy/env_file".path; systemd.services.caddy.serviceConfig.EnvironmentFile = config.sops.secrets."caddy/env_file".path;
networking.firewall.allowedTCPPorts = [ 80 443 ]; networking.firewall.allowedTCPPorts = [ 80 443 ];

View file

@ -1,7 +1,16 @@
{ lib, config, ... }: { { lib, config, ... }:
let
inherit (import ./caddy-helpers.nix) logFormat;
in
{
services = { services = {
caddy = { caddy =
virtualHosts."${config.networking.hostName}.labs.adtya.xyz" = { let
vHost = "${config.networking.hostName}.labs.adtya.xyz";
in
{
virtualHosts."${vHost}" = {
logFormat = logFormat vHost;
extraConfig = '' extraConfig = ''
metrics /caddy-metrics metrics /caddy-metrics
handle /metrics { handle /metrics {