aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/leila/production.nix
blob: 4390d592d7e99039bc70ccaf45eba24c6183ef08 (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
{ lib, pkgs, config, ... }:
let
  cfg = config.myServices.websites.leila.production;
  varDir = "/var/lib/ftp/leila";
in {
  options.myServices.websites.leila.production.enable = lib.mkEnableOption "enable Leila's websites in production";

  config = lib.mkIf cfg.enable {
    services.phpfpm.poolConfigs.leila = ''
      listen = /run/phpfpm/leila.sock
      user = wwwrun
      group = wwwrun
      listen.owner = wwwrun
      listen.group = wwwrun

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

      php_admin_value[open_basedir] = "${varDir}:/tmp"
      '';

    services.webstats.sites = [
      { name = "leila.bouya.org"; }
      { name = "chorale.leila.bouya.org"; }
      { name = "syrwennecreation.bouya.org"; }
    ];

    services.websites.env.production.modules = [ "proxy_fcgi" ];
    services.websites.env.production.vhostConfs.leila_chorale = {
      certName    = "leila";
      addToCerts  = true;
      hosts       = [ "chorale.leila.bouya.org" "chorale-vocanta.fr.nf" "www.chorale-vocanta.fr.nf" ];
      root        = "${varDir}/Chorale";
      extraConfig = [
        ''
        Use Stats chorale.leila.bouya.org
        <Directory ${varDir}/Chorale>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None

          Use LDAPConnect
          Require ldap-group cn=chorale.leila.bouya.org,cn=httpd,ou=services,dc=immae,dc=eu

          <FilesMatch "\.php$">
            SetHandler "proxy:unix:/run/phpfpm/leila.sock|fcgi://localhost"
          </FilesMatch>
        </Directory>
          ''
      ];
    };
    services.websites.env.production.vhostConfs.leila_syrwenne = {
      certName    = "leila";
      addToCerts  = true;
      hosts       = [ "syrwennecreation.bouya.org" ];
      root        = "${varDir}/Syrwennecreation";
      extraConfig = [
        ''
        Use Stats syrwennecreation.bouya.org
        <Directory ${varDir}/Syrwennecreation>
          DirectoryIndex index.php index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None

          <FilesMatch "\.php$">
            SetHandler "proxy:unix:/run/phpfpm/leila.sock|fcgi://localhost"
          </FilesMatch>
        </Directory>
          ''
      ];
    };
    services.websites.env.production.vhostConfs.leila = {
      certName     = "leila";
      certMainHost = "leila.bouya.org";
      hosts        = [ "leila.bouya.org" ];
      root         = varDir;
      extraConfig  = [
        ''
        Use Stats leila.bouya.org
        <Directory ${varDir}/Chorale>
          DirectoryIndex index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None

          Use LDAPConnect
          Require ldap-group cn=chorale.leila.bouya.org,cn=httpd,ou=services,dc=immae,dc=eu

          <FilesMatch "\.php$">
            SetHandler "proxy:unix:/run/phpfpm/leila.sock|fcgi://localhost"
          </FilesMatch>
        </Directory>
        <Directory ${varDir}>
          DirectoryIndex index.htm index.html
          Options Indexes FollowSymLinks MultiViews Includes
          AllowOverride None
          Require all granted
        </Directory>
          ''
      ];
    };
  };
}