]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add statistics for aten website
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 6 Jan 2019 11:43:51 +0000 (12:43 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sun, 6 Jan 2019 11:43:51 +0000 (12:43 +0100)
default.nix
virtual/eldiron.nix
virtual/packages/aten.nix
virtual/packages/aten_goaccess.conf [new file with mode: 0644]

index 4e50c59f397510a10e7a725c6a18a4f55a9d757c..c2776023bf5627eb12a4cab6bdd2afd1dff180a8 100644 (file)
@@ -241,6 +241,17 @@ let
   #     '';
   # });
 
   #     '';
   # });
 
+  mypkgs.goaccess = goaccess.overrideAttrs(old: rec {
+    name = "goaccess-${version}";
+    version = "1.3";
+    src = fetchurl {
+      url = "https://tar.goaccess.io/${name}.tar.gz";
+      sha256 = "16vv3pj7pbraq173wlxa89jjsd279004j4kgzlrsk1dz4if5qxwc";
+    };
+    configureFlags = old.configureFlags ++ [ "--enable-tcb=btree" ];
+    buildInputs = old.buildInputs ++ [ tokyocabinet bzip2 ];
+  });
+
   mastodon = stdenv.mkDerivation (fetchedGithub ./fetched/mastodon.json // rec {
     buildPhase = ''
       export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
   mastodon = stdenv.mkDerivation (fetchedGithub ./fetched/mastodon.json // rec {
     buildPhase = ''
       export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
index 68eddf607446c5630f46ac13b9659271893c6377..c1a7761c3802aebebdf98b84045a400b3f78e259 100644 (file)
         cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ];
         buildInputs = old.buildInputs ++ [ pkgs.pam ];
       });
         cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ];
         buildInputs = old.buildInputs ++ [ pkgs.pam ];
       });
+      goaccess = oldpkgs.goaccess.overrideAttrs(old: rec {
+        name = "goaccess-${version}";
+        version = "1.3";
+        src = pkgs.fetchurl {
+          url = "https://tar.goaccess.io/${name}.tar.gz";
+          sha256 = "16vv3pj7pbraq173wlxa89jjsd279004j4kgzlrsk1dz4if5qxwc";
+        };
+        configureFlags = old.configureFlags ++ [ "--enable-tcb=btree" ];
+        buildInputs = old.buildInputs ++ [ pkgs.tokyocabinet pkgs.bzip2 ];
+      });
     };
 
     networking = {
     };
 
     networking = {
@@ -85,6 +95,7 @@
     in [
       pkgs.telnet
       pkgs.vim
     in [
       pkgs.telnet
       pkgs.vim
+      pkgs.goaccess
       occ
     ];
 
       occ
     ];
 
           fi
         '';
       };
           fi
         '';
       };
+      goaccess = ''
+        mkdir -p /var/lib/goaccess
+        mkdir -p /var/lib/goaccess/aten.pro
+        '';
     };
 
     environment.etc."ssh/ldap_authorized_keys" = let
     };
 
     environment.etc."ssh/ldap_authorized_keys" = let
                 AuthBasicProvider    ldap
               </IfModule>
             </Macro>
                 AuthBasicProvider    ldap
               </IfModule>
             </Macro>
+
+            <Macro Stats %{domain}>
+              Alias /awstats /var/lib/goaccess/%{domain}
+              <Directory /var/lib/goaccess/%{domain}>
+                DirectoryIndex index.html
+                AllowOverride None
+                Require all granted
+              </Directory>
+              <Location /awstats>
+                Use LDAPConnect
+                Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
+              </Location>
+            </Macro>
           '';
         };
         http2 = {
           '';
         };
         http2 = {
         customLog = {
           modules = [];
           extraConfig = ''
         customLog = {
           modules = [];
           extraConfig = ''
-            LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %p" combinedVhost
+            LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost
           '';
         };
       };
           '';
         };
       };
         #host  all     all             all                     pam
       '';
     };
         #host  all     all             all                     pam
       '';
     };
+
+    services.cron = {
+      enable = true;
+      systemCronJobs = let
+        stats = domain: conf: "${pkgs.gnused}/bin/sed -n '/\\['$(LC_ALL=C ${pkgs.coreutils}/bin/date -d yesterday +'%d\\/%b\\/%Y')'/ p' /var/log/httpd/access_log-${domain} | ${pkgs.goaccess}/bin/goaccess -o /var/lib/goaccess/${domain}/index.html -p ${conf}";
+      in [
+        "5 0 * * * root ${stats "aten.pro" ./packages/aten_goaccess.conf}"
+        ];
+    };
   };
 }
   };
 }
index 016676f92aaa913d179ef28f1c0acac28d8efba8..21bbff07df30f62d2a74ec5aec68229ec9359007 100644 (file)
@@ -37,6 +37,8 @@ let
         assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
         assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
       ''
         assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
         assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
       ''
+      Use Stats aten.pro
+
       <FilesMatch "\.php$">
         SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
       </FilesMatch>
       <FilesMatch "\.php$">
         SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
       </FilesMatch>
diff --git a/virtual/packages/aten_goaccess.conf b/virtual/packages/aten_goaccess.conf
new file mode 100644 (file)
index 0000000..07cce57
--- /dev/null
@@ -0,0 +1,99 @@
+time-format %H:%M:%S
+date-format %d/%b/%Y
+
+#sur immae.eu
+#log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^
+
+log-format VCOMBINED
+#= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
+
+html-prefs {"theme":"bright","layout":"vertical"}
+
+exclude-ip 188.165.209.148
+exclude-ip 178.33.252.96
+exclude-ip 2001:41d0:2:9c94::1
+exclude-ip 2001:41d0:2:9c94::
+exclude-ip 176.9.151.89
+exclude-ip 2a01:4f8:160:3445::
+exclude-ip 82.255.56.72
+
+no-query-string true
+
+keep-db-files true
+load-from-disk true
+db-path /var/lib/goaccess/aten.pro
+
+ignore-panel REFERRERS
+ignore-panel KEYPHRASES
+
+static-file .css
+static-file .js
+static-file .jpg
+static-file .png
+static-file .gif
+static-file .ico
+static-file .jpeg
+static-file .pdf
+static-file .csv
+static-file .mpeg
+static-file .mpg
+static-file .swf
+static-file .woff
+static-file .woff2
+static-file .xls
+static-file .xlsx
+static-file .doc
+static-file .docx
+static-file .ppt
+static-file .pptx
+static-file .txt
+static-file .zip
+static-file .ogg
+static-file .mp3
+static-file .mp4
+static-file .exe
+static-file .iso
+static-file .gz
+static-file .rar
+static-file .svg
+static-file .bmp
+static-file .tar
+static-file .tgz
+static-file .tiff
+static-file .tif
+static-file .ttf
+static-file .flv
+#static-file .less
+#static-file .ac3
+#static-file .avi
+#static-file .bz2
+#static-file .class
+#static-file .cue
+#static-file .dae
+#static-file .dat
+#static-file .dts
+#static-file .ejs
+#static-file .eot
+#static-file .eps
+#static-file .img
+#static-file .jar
+#static-file .map
+#static-file .mid
+#static-file .midi
+#static-file .ogv
+#static-file .webm
+#static-file .mkv
+#static-file .odp
+#static-file .ods
+#static-file .odt
+#static-file .otf
+#static-file .pict
+#static-file .pls
+#static-file .ps
+#static-file .qt
+#static-file .rm
+#static-file .svgz
+#static-file .wav
+#static-file .webp
+
+