aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/evariste/production.nix
blob: 43b26c809e70e0653a07dcb109c43bd0024e2699 (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
{ lib, pkgs, config,  ... }:
let
  cfg = config.myServices.websites.evariste.production;
  nsiVarDir = "/var/lib/ftp/nsievariste";
  stmgVarDir = "/var/lib/ftp/stmgevariste";
in {
  options.myServices.websites.evariste.production.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.evariste = {
      deps = [ "httpd" ];
      text = ''
        install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/nsievariste
        install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/stmgevariste
        '';
    };
    services.phpfpm.pools.nsievariste = {
      user = "wwwrun";
      group = "wwwrun";
      settings = {
        "listen.owner" = "wwwrun";
        "listen.group" = "wwwrun";

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

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

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.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.stmgevariste = {
      user = "wwwrun";
      group = "wwwrun";
      settings = {
        "listen.owner" = "wwwrun";
        "listen.group" = "wwwrun";

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

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

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.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>
          ''
      ];
    };
  };
}