all: reformat caddy logs
This commit is contained in:
parent
4bb172fa9e
commit
29555fda8b
5 changed files with 59 additions and 24 deletions
|
@ -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
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -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
|
||||||
'';
|
'';
|
||||||
|
|
11
hosts/shared/caddy-helpers.nix
Normal file
11
hosts/shared/caddy-helpers.nix
Normal 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
|
||||||
|
'';
|
||||||
|
}
|
|
@ -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 ];
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue