aboutsummaryrefslogtreecommitdiff
path: root/systems/eldiron/websites/tools/adminer.nix
blob: 5e865b1fe9494aa738edfa2b22c5a3c101f1b496 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ config, webapps-adminer, php82, lib, forcePhpSocket ? null }:
rec {
  webRoot = webapps-adminer;
  phpFpm = rec {
    user = apache.user;
    group = apache.group;
    phpPackage = let
      #mysqli_pam = php81.extensions.mysqli.overrideAttrs(old: {
      #  configureFlags = [ "--with-mysqli=${libmysqlclient_pam.dev}/bin/mysql_config" "--with-mysql-sock=/run/mysqld/mysqld.sock" ];
      #});
    in
      php82.withExtensions ({ enabled, all }: [all.mysqli all.redis all.pgsql]);
    settings = {
      "listen.owner" = apache.user;
      "listen.group" = apache.group;
      "pm" = "ondemand";
      "pm.max_children" = "5";
      "pm.process_idle_timeout" = "60";
      #"php_admin_flag[log_errors]" = "on";
      # Needed to avoid clashes in browser cookies (same domain)
      "php_value[session.name]" = "AdminerPHPSESSID";
      "php_admin_value[open_basedir]" = "${webRoot}:/tmp";
      "php_admin_value[session.save_handler]" = "redis";
      "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=Tools:Adminer:'";
    };
  };
  apache = rec {
    user = "wwwrun";
    group = "wwwrun";
    modules = [ "proxy_fcgi" ];
    root = webRoot;
    vhostConf = socket: ''
      Alias /adminer ${webRoot}
      <Directory ${webRoot}>
        DirectoryIndex index.php
        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${if forcePhpSocket != null then forcePhpSocket else socket}|fcgi://localhost"
        </FilesMatch>

        Use LDAPConnect
        Require ldap-group cn=users,cn=mysql,cn=pam,ou=services,dc=immae,dc=eu
        Require ldap-group cn=users,cn=postgresql,cn=pam,ou=services,dc=immae,dc=eu
      </Directory>
      '';
  };
  monitoringPlugins = [ "http" ];
  monitoringObjects.service = [
    {
      service_description = "adminer website is running on tools.immae.eu";
      host_name = config.hostEnv.fqdn;
      use = "external-web-service";
      check_command = ["check_https_auth" "tools.immae.eu" "/adminer/" "www.adminerevo.org"];

      servicegroups = "webstatus-webapps";
      _webstatus_name = "Adminer";
      _webstatus_url = "https://tools.immae.eu/adminer/";
    }
  ];

  chatonsProperties = {
    published = false;
    file.datetime = "2023-08-21T15:20:00";
    service = {
      name = "Adminer";
      description = "Database management in a single PHP file";
      website = "https://tools.immae.eu/adminer/";
      logo = "https://tools.immae.eu/adminer/?file=favicon.ico";
      status.level = "OK";
      status.description = "OK";
      registration."" = ["MEMBER" "CLIENT"];
      registration.load = "OPEN";
      install.type = "PACKAGE";
    };
    software = {
      name = "Adminer";
      website = "https://docs.adminerevo.org/";
      license.url = "https://github.com/adminerevo/adminerevo/blob/main/readme.md";
      license.name = "Apache License 2.0 or GPL 2";
      version = webRoot.version;
      source.url = "https://github.com/adminerevo/adminerevo/";
    };
  };
}