aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/denise/evariste.nix
blob: 42f9b2e33c8dc8c65f7fa5c6186672330da6fc6c (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{ lib, config, pkgs, ... }:
let
  cfg = config.myServices.websites.denise.evariste;
  nsiVarDir = "/var/lib/ftp/denise/nsievariste";
  stmgVarDir = "/var/lib/ftp/denise/stmgevariste";
  apacheUser = config.services.httpd.Prod.user;
  apacheGroup = config.services.httpd.Prod.group;
in {
  options.myServices.websites.denise.evariste.enable = lib.mkEnableOption "enable NSI/STMG Evariste website";

  config = lib.mkIf cfg.enable {
    services.webstats.sites = [
      { name = "nsievariste.immae.eu"; }
      { name = "stmgevariste.immae.eu"; }
    ];

    services.websites.env.production.modules = [ "proxy_fcgi" ];
    system.activationScripts.denise_evariste = {
      deps = [ "httpd" ];
      text = ''
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/denise_nsievariste
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/denise_stmgevariste
        '';
    };
    services.phpfpm.pools.denise_nsievariste = {
      user = apacheUser;
      group = apacheGroup;
      settings = {
        "listen.owner" = apacheUser;
        "listen.group" = apacheGroup;

        "pm" = "ondemand";
        "pm.max_children" = "5";
        "pm.process_idle_timeout" = "60";

        "php_admin_value[open_basedir]" = "/var/lib/php/sessions/denise_nsievariste:${nsiVarDir}:/tmp";
        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/denise_nsievariste";
      };
      phpPackage = pkgs.php72;
    };
    services.websites.env.production.vhostConfs.denise_nsievariste = {
      certName     = "denise_evariste";
      addToCerts   = true;
      certMainHost = "nsievariste.immae.eu";
      hosts        = ["nsievariste.immae.eu" ];
      root         = nsiVarDir;
      extraConfig  = [
        ''
        Use Stats nsievariste.immae.eu

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.denise_nsievariste.socket}|fcgi://localhost"
        </FilesMatch>

        <Directory ${nsiVarDir}>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None
          Require all granted
        </Directory>
          ''
      ];
    };

    services.phpfpm.pools.denise_stmgevariste = {
      user = apacheUser;
      group = apacheGroup;
      settings = {
        "listen.owner" = apacheUser;
        "listen.group" = apacheGroup;

        "pm" = "ondemand";
        "pm.max_children" = "5";
        "pm.process_idle_timeout" = "60";

        "php_admin_value[open_basedir]" = "/var/lib/php/sessions/denise_stmgevariste:${stmgVarDir}:/tmp";
        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/denise_stmgevariste";
      };
      phpPackage = pkgs.php72;
    };
    services.websites.env.production.vhostConfs.denise_stmgevariste = {
      certName     = "denise_evariste";
      addToCerts   = true;
      hosts        = ["stmgevariste.immae.eu" ];
      root         = stmgVarDir;
      extraConfig  = [
        ''
        Use Stats stmgevariste.immae.eu

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.denise_stmgevariste.socket}|fcgi://localhost"
        </FilesMatch>

        <Directory ${stmgVarDir}>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None
          Require all granted
        </Directory>
          ''
      ];
    };
  };
}