aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/emilia/atelierfringant.nix
blob: b47452f5068385a3d9d2e01f0475e9a4d0e51e36 (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
{ lib, pkgs, config,  ... }:
let
  cfg = config.myServices.websites.emilia.atelierfringant;
  varDir = "/var/lib/ftp/emilia/atelierfringant";
  apacheUser = config.services.httpd.Prod.user;
  apacheGroup = config.services.httpd.Prod.group;
in {
  options.myServices.websites.emilia.atelierfringant.enable = lib.mkEnableOption "enable Émilia's website";

  config = lib.mkIf cfg.enable {
    system.activationScripts.emilia_atelierfringant = {
      deps = [ "httpd" ];
      text = ''
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/ftp/emilia/atelierfringant
        install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/emilia
        '';
    };
    systemd.services.phpfpm-emilia_atelierfringant.after = lib.mkAfter [ "mysql.service" ];
    systemd.services.phpfpm-emilia_atelierfringant.wants = [ "mysql.service" ];
    services.phpfpm.pools.emilia_atelierfringant = {
      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/emilia:${varDir}:/tmp";
        "php_admin_value[session.save_path]" = "/var/lib/php/sessions/emilia";
      };
      phpOptions = config.services.phpfpm.phpOptions + ''
        disable_functions = "mail"
      '';
      phpPackage = pkgs.php72;
    };
    services.websites.env.production.modules = [ "proxy_fcgi" ];
    services.websites.env.production.vhostConfs.emilia_atelierfringant = {
      certName     = "emilia";
      certMainHost = "atelierfringant.org";
      hosts        = ["atelierfringant.org" "www.atelierfringant.org" ];
      root         = varDir;
      extraConfig  = [
        ''
        <FilesMatch "\.php$">
          SetHandler "proxy:unix:${config.services.phpfpm.pools.emilia_atelierfringant.socket}|fcgi://localhost"
        </FilesMatch>

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