summaryrefslogtreecommitdiff
path: root/nixos/helpers.nix
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-03-27 08:09:26 +0100
committerMartin Fischer <martin@push-f.com>2025-03-27 19:50:24 +0100
commit2616e00a5310e1755fdec02147f1110221fb6d36 (patch)
tree6fcfcbf9c348beee3dc973a1f11b2d9776e26a74 /nixos/helpers.nix
parent5a0c9eb79b5618c4894397646788e77db90429e0 (diff)
tweak(tente): rotate matrix nginx access logs daily
Diffstat (limited to 'nixos/helpers.nix')
-rw-r--r--nixos/helpers.nix14
1 files changed, 14 insertions, 0 deletions
diff --git a/nixos/helpers.nix b/nixos/helpers.nix
index de00136..c6d1ff8 100644
--- a/nixos/helpers.nix
+++ b/nixos/helpers.nix
@@ -9,6 +9,20 @@ in
error_log /var/log/nginx/${name}.error.log;
'';
+ # Returns the default nginx logrotate settings for a specific virtual host.
+ mkNginxAccessLogrotateSettings = name: {
+ ignoreduplicates = true; # ignore any following matches (otherwise we get a 'duplicate log entry' error)
+ priority = 100; # default is 1000, smaller values are inserted first
+
+ files = [ "/var/log/nginx/${name}.access.log" ];
+ frequency = "weekly";
+ su = "${config.services.nginx.user} ${config.services.nginx.group}";
+ rotate = 26;
+ compress = true;
+ delaycompress = true;
+ postrotate = "[ ! -f /var/run/nginx/nginx.pid ] || kill -USR1 `cat /var/run/nginx/nginx.pid`";
+ };
+
commonHttpConfig = ''
map $request_uri $request_uri_path {
"~^(?P<path>[^?]*)(\?.*)?$" $path;