mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-01-21 19:51:34 +01:00
Fix crowdsec's acquisition of caddy logs
This commit is contained in:
parent
e7cdd49bcf
commit
a1481db722
2 changed files with 10 additions and 2 deletions
|
|
@ -54,6 +54,7 @@ in
|
||||||
virtualHosts = lib.mapAttrs' (
|
virtualHosts = lib.mapAttrs' (
|
||||||
_: value:
|
_: value:
|
||||||
lib.nameValuePair value.domain {
|
lib.nameValuePair value.domain {
|
||||||
|
logFormat = "output file ${config.services.caddy.logDir}/access-${value.domain}.log { mode 640 }";
|
||||||
extraConfig = lib.concatStrings [
|
extraConfig = lib.concatStrings [
|
||||||
(lib.optionalString (isTailscaleDomain value.domain) ''
|
(lib.optionalString (isTailscaleDomain value.domain) ''
|
||||||
bind tailscale/${getSubdomain value.domain}
|
bind tailscale/${getSubdomain value.domain}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.custom.services.crowdsec;
|
cfg = config.custom.services.crowdsec;
|
||||||
|
|
||||||
|
user = config.users.users.crowdsec.name;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ inputs.crowdsec.nixosModules.crowdsec ];
|
imports = [ inputs.crowdsec.nixosModules.crowdsec ];
|
||||||
|
|
@ -32,7 +34,9 @@ in
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
nixpkgs.overlays = [ inputs.crowdsec.overlays.default ];
|
nixpkgs.overlays = [ inputs.crowdsec.overlays.default ];
|
||||||
|
|
||||||
sops.secrets."crowdsec/enrollment-key".owner = config.users.users.crowdsec.name;
|
sops.secrets."crowdsec/enrollment-key".owner = user;
|
||||||
|
|
||||||
|
users.groups.caddy.members = lib.mkIf (lib.elem "caddy" cfg.sources) [ user ];
|
||||||
|
|
||||||
services.crowdsec = {
|
services.crowdsec = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
@ -53,7 +57,10 @@ in
|
||||||
in
|
in
|
||||||
[
|
[
|
||||||
(mkAcquisition (lib.elem "sshd" cfg.sources) "sshd.service")
|
(mkAcquisition (lib.elem "sshd" cfg.sources) "sshd.service")
|
||||||
(mkAcquisition (lib.elem "caddy" cfg.sources) "caddy.service")
|
(lib.mkIf (lib.elem "caddy" cfg.sources) {
|
||||||
|
filenames = [ "${config.services.caddy.logDir}/*.log" ];
|
||||||
|
labels.type = "caddy";
|
||||||
|
})
|
||||||
(lib.mkIf (lib.elem "iptables" cfg.sources) {
|
(lib.mkIf (lib.elem "iptables" cfg.sources) {
|
||||||
source = "journalctl";
|
source = "journalctl";
|
||||||
journalctl_filter = [ "-k" ];
|
journalctl_filter = [ "-k" ];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue