]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add Jerome's ftp website
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 29 Jan 2019 07:33:53 +0000 (08:33 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Tue, 29 Jan 2019 07:34:48 +0000 (08:34 +0100)
Related issue: https://git.immae.eu/mantisbt/view.php?id=77

nixops/modules/websites/default.nix
nixops/modules/websites/ftp/jerome.nix [new file with mode: 0644]
nixops/modules/websites/ftp/jerome_goaccess.conf [new file with mode: 0644]

index 4d5ae23d3564f83403dfca8332c0125917f94ada..9befdd166e3175d574448d0dd68538fbd81cb94d 100644 (file)
@@ -91,6 +91,7 @@ in
     ./piedsjaloux
     ./connexionswing
     ./tellesflorian
+    ./ftp/jerome.nix
     ./tools/db
     ./tools/tools
     ./tools/dav
@@ -187,6 +188,7 @@ in
     services.myWebsites.Aten.production.enable = cfg.production.enable;
     services.myWebsites.PiedsJaloux.production.enable = cfg.production.enable;
     services.myWebsites.Connexionswing.production.enable = cfg.production.enable;
+    services.myWebsites.Jerome.production.enable = cfg.production.enable;
 
     services.myWebsites.Chloe.integration.enable = cfg.integration.enable;
     services.myWebsites.Ludivine.integration.enable = cfg.integration.enable;
diff --git a/nixops/modules/websites/ftp/jerome.nix b/nixops/modules/websites/ftp/jerome.nix
new file mode 100644 (file)
index 0000000..199bfab
--- /dev/null
@@ -0,0 +1,96 @@
+{ lib, pkgs, config, myconfig, mylibs, ... }:
+let
+    adminer = pkgs.callPackage ../commons/adminer.nix {};
+    cfg = config.services.myWebsites.Jerome;
+    varDir = "/var/lib/ftp/jerome";
+    env = myconfig.env.websites.jerome;
+in {
+  options.services.myWebsites.Jerome = {
+    production = {
+      enable = lib.mkEnableOption "enable Jerome's website";
+    };
+  };
+
+  imports = [
+    ../commons/stats.nix
+  ];
+
+  config = lib.mkIf cfg.production.enable {
+    services.myWebsites.commons.stats.enable = true;
+    services.myWebsites.commons.stats.sites = [
+      {
+        name = "naturaloutil.immae.eu";
+        conf = ./jerome_goaccess.conf;
+      }
+    ];
+
+    security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null;
+    security.acme.certs."naturaloutil" = config.services.myCertificates.certConfig // {
+      domain = "naturaloutil.immae.eu";
+    };
+
+    services.myPhpfpm.poolConfigs.jerome = let
+      configFile = pkgs.writeText "naturaloutil.inc.php" ''
+        <?php
+        $mysql_user = '${env.mysql.user}' ;
+        $mysql_server = '${env.mysql.host}' ;
+        $mysql_base = '${env.mysql.name}' ;
+        $mysql_password = '${env.mysql.password}' ;
+        //connect to db
+        $db = mysqli_init();
+        ${if env.mysql.host != "localhost" then ''
+        mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
+        $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL);
+        '' else ""}
+        $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password);
+        ?>
+        '';
+      in ''
+      listen = /run/phpfpm/naturaloutil.sock
+      user = wwwrun
+      group = wwwrun
+      listen.owner = wwwrun
+      listen.group = wwwrun
+
+      pm = ondemand
+      pm.max_children = 5
+      pm.process_idle_timeout = 60
+
+      env[BDD_CONNECT] = "${configFile}"
+      php_admin_value[open_basedir] = "${configFile}:${varDir}:/tmp"
+      '';
+    services.myPhpfpm.poolPhpConfigs.jerome = ''
+      extension=${pkgs.php}/lib/php/extensions/mysqli.so
+      '';
+    services.myWebsites.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
+    services.myWebsites.production.vhostConfs.naturaloutil = {
+      certName    = "naturaloutil";
+      hosts       = ["naturaloutil.immae.eu" ];
+      root        = varDir;
+      extraConfig = [
+        adminer.apache.vhostConf
+        ''
+        Use Stats naturaloutil.immae.eu
+        ServerAdmin ${env.server_admin}
+        ErrorLog "${varDir}/logs/error_log"
+        CustomLog "${varDir}/logs/access_log" combined
+
+        <FilesMatch "\.php$">
+          SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost"
+        </FilesMatch>
+
+        <Directory ${varDir}/logs>
+          AllowOverride None
+          Require all denied
+        </Directory>
+        <Directory ${varDir}>
+          DirectoryIndex index.php index.htm index.html
+          Options Indexes FollowSymLinks MultiViews Includes
+          AllowOverride None
+          Require all granted
+        </Directory>
+          ''
+      ];
+    };
+  };
+}
diff --git a/nixops/modules/websites/ftp/jerome_goaccess.conf b/nixops/modules/websites/ftp/jerome_goaccess.conf
new file mode 100644 (file)
index 0000000..83c59e2
--- /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/naturaloutil.immae.eu
+
+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
+
+