aboutsummaryrefslogtreecommitdiff
path: root/virtual
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-06 12:43:51 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-06 12:43:51 +0100
commit6f0d92b429069069e6d914f25bb30a549526f9d8 (patch)
tree190b893e91a1414c81276498dcd571e79e89660f /virtual
parent6c672f344e2de6852cfa97ed789726bcd54cc83c (diff)
downloadNix-6f0d92b429069069e6d914f25bb30a549526f9d8.tar.gz
Nix-6f0d92b429069069e6d914f25bb30a549526f9d8.tar.zst
Nix-6f0d92b429069069e6d914f25bb30a549526f9d8.zip
Add statistics for aten website
Diffstat (limited to 'virtual')
-rw-r--r--virtual/eldiron.nix39
-rw-r--r--virtual/packages/aten.nix2
-rw-r--r--virtual/packages/aten_goaccess.conf99
3 files changed, 139 insertions, 1 deletions
diff --git a/virtual/eldiron.nix b/virtual/eldiron.nix
index 68eddf6..c1a7761 100644
--- a/virtual/eldiron.nix
+++ b/virtual/eldiron.nix
@@ -42,6 +42,16 @@
42 cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ]; 42 cmakeFlags = old.cmakeFlags ++ [ "-DWITH_AUTHENTICATION_PAM=ON" ];
43 buildInputs = old.buildInputs ++ [ pkgs.pam ]; 43 buildInputs = old.buildInputs ++ [ pkgs.pam ];
44 }); 44 });
45 goaccess = oldpkgs.goaccess.overrideAttrs(old: rec {
46 name = "goaccess-${version}";
47 version = "1.3";
48 src = pkgs.fetchurl {
49 url = "https://tar.goaccess.io/${name}.tar.gz";
50 sha256 = "16vv3pj7pbraq173wlxa89jjsd279004j4kgzlrsk1dz4if5qxwc";
51 };
52 configureFlags = old.configureFlags ++ [ "--enable-tcb=btree" ];
53 buildInputs = old.buildInputs ++ [ pkgs.tokyocabinet pkgs.bzip2 ];
54 });
45 }; 55 };
46 56
47 networking = { 57 networking = {
@@ -85,6 +95,7 @@
85 in [ 95 in [
86 pkgs.telnet 96 pkgs.telnet
87 pkgs.vim 97 pkgs.vim
98 pkgs.goaccess
88 occ 99 occ
89 ]; 100 ];
90 101
@@ -247,6 +258,10 @@
247 fi 258 fi
248 ''; 259 '';
249 }; 260 };
261 goaccess = ''
262 mkdir -p /var/lib/goaccess
263 mkdir -p /var/lib/goaccess/aten.pro
264 '';
250 }; 265 };
251 266
252 environment.etc."ssh/ldap_authorized_keys" = let 267 environment.etc."ssh/ldap_authorized_keys" = let
@@ -313,6 +328,19 @@
313 AuthBasicProvider ldap 328 AuthBasicProvider ldap
314 </IfModule> 329 </IfModule>
315 </Macro> 330 </Macro>
331
332 <Macro Stats %{domain}>
333 Alias /awstats /var/lib/goaccess/%{domain}
334 <Directory /var/lib/goaccess/%{domain}>
335 DirectoryIndex index.html
336 AllowOverride None
337 Require all granted
338 </Directory>
339 <Location /awstats>
340 Use LDAPConnect
341 Require ldap-group cn=%{domain},ou=stats,cn=httpd,ou=services,dc=immae,dc=eu
342 </Location>
343 </Macro>
316 ''; 344 '';
317 }; 345 };
318 http2 = { 346 http2 = {
@@ -324,7 +352,7 @@
324 customLog = { 352 customLog = {
325 modules = []; 353 modules = [];
326 extraConfig = '' 354 extraConfig = ''
327 LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %p" combinedVhost 355 LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedVhost
328 ''; 356 '';
329 }; 357 };
330 }; 358 };
@@ -525,5 +553,14 @@
525 #host all all all pam 553 #host all all all pam
526 ''; 554 '';
527 }; 555 };
556
557 services.cron = {
558 enable = true;
559 systemCronJobs = let
560 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}";
561 in [
562 "5 0 * * * root ${stats "aten.pro" ./packages/aten_goaccess.conf}"
563 ];
564 };
528 }; 565 };
529} 566}
diff --git a/virtual/packages/aten.nix b/virtual/packages/aten.nix
index 016676f..21bbff0 100644
--- a/virtual/packages/aten.nix
+++ b/virtual/packages/aten.nix
@@ -37,6 +37,8 @@ let
37 assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET"; 37 assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
38 assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"; 38 assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
39 '' 39 ''
40 Use Stats aten.pro
41
40 <FilesMatch "\.php$"> 42 <FilesMatch "\.php$">
41 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" 43 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
42 </FilesMatch> 44 </FilesMatch>
diff --git a/virtual/packages/aten_goaccess.conf b/virtual/packages/aten_goaccess.conf
new file mode 100644
index 0000000..07cce57
--- /dev/null
+++ b/virtual/packages/aten_goaccess.conf
@@ -0,0 +1,99 @@
1time-format %H:%M:%S
2date-format %d/%b/%Y
3
4#sur immae.eu
5#log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^
6
7log-format VCOMBINED
8#= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
9
10html-prefs {"theme":"bright","layout":"vertical"}
11
12exclude-ip 188.165.209.148
13exclude-ip 178.33.252.96
14exclude-ip 2001:41d0:2:9c94::1
15exclude-ip 2001:41d0:2:9c94::
16exclude-ip 176.9.151.89
17exclude-ip 2a01:4f8:160:3445::
18exclude-ip 82.255.56.72
19
20no-query-string true
21
22keep-db-files true
23load-from-disk true
24db-path /var/lib/goaccess/aten.pro
25
26ignore-panel REFERRERS
27ignore-panel KEYPHRASES
28
29static-file .css
30static-file .js
31static-file .jpg
32static-file .png
33static-file .gif
34static-file .ico
35static-file .jpeg
36static-file .pdf
37static-file .csv
38static-file .mpeg
39static-file .mpg
40static-file .swf
41static-file .woff
42static-file .woff2
43static-file .xls
44static-file .xlsx
45static-file .doc
46static-file .docx
47static-file .ppt
48static-file .pptx
49static-file .txt
50static-file .zip
51static-file .ogg
52static-file .mp3
53static-file .mp4
54static-file .exe
55static-file .iso
56static-file .gz
57static-file .rar
58static-file .svg
59static-file .bmp
60static-file .tar
61static-file .tgz
62static-file .tiff
63static-file .tif
64static-file .ttf
65static-file .flv
66#static-file .less
67#static-file .ac3
68#static-file .avi
69#static-file .bz2
70#static-file .class
71#static-file .cue
72#static-file .dae
73#static-file .dat
74#static-file .dts
75#static-file .ejs
76#static-file .eot
77#static-file .eps
78#static-file .img
79#static-file .jar
80#static-file .map
81#static-file .mid
82#static-file .midi
83#static-file .ogv
84#static-file .webm
85#static-file .mkv
86#static-file .odp
87#static-file .ods
88#static-file .odt
89#static-file .otf
90#static-file .pict
91#static-file .pls
92#static-file .ps
93#static-file .qt
94#static-file .rm
95#static-file .svgz
96#static-file .wav
97#static-file .webp
98
99