aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/teliotortay/production.nix
blob: 2c62d101f851fab630e91edde72cac3af4945be4 (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
{ lib, pkgs, config,  ... }:
let
  adminer = pkgs.callPackage ../commons/adminer.nix {};
  cfg = config.myServices.websites.telioTortay.production;
  varDir = "/var/lib/ftp/telio_tortay";
  env = config.myEnv.websites.telioTortay;
in {
  options.myServices.websites.telioTortay.production.enable = lib.mkEnableOption "enable Telio Tortay's website";

  config = lib.mkIf cfg.enable {
    services.webstats.sites = [ { name = "telio-tortay.immae.eu"; } ];

    security.acme2.certs."ftp".extraDomains."telio-tortay.immae.eu" = null;

    system.activationScripts.telio-tortay = {
      deps = [ "httpd" ];
      text = ''
        install -m 0755 -o wwwrun -g wwwrun -d /var/lib/ftp/telio_tortay/logs
        install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/telio-tortay
        '';
    };
    systemd.services.phpfpm-telio-tortay.after = lib.mkAfter [ "mysql.service" ];
    systemd.services.phpfpm-telio-tortay.wants = [ "mysql.service" ];
    services.phpfpm.pools.telio-tortay = {
      listen = "/run/phpfpm/telio-tortay.sock";
      extraConfig = ''
        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] = "/var/lib/php/sessions/telio-tortay:${varDir}:/tmp"
        php_admin_value[session.save_path] = "/var/lib/php/sessions/telio-tortay"
        '';
      phpOptions = config.services.phpfpm.phpOptions + ''
        disable_functions = "mail"
        extension=${pkgs.php}/lib/php/extensions/mysqli.so
        '';
    };
    services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
    services.websites.env.production.vhostConfs.telio-tortay = {
      certName     = "telio-tortay";
      certMainHost = "telio-tortay.immae.eu";
      hosts        = ["telio-tortay.immae.eu" "realistesmedia.fr" "www.realistesmedia.fr" ];
      root         = varDir;
      extraConfig  = [
        adminer.apache.vhostConf
        ''
        Use Stats telio-tortay.immae.eu
        ServerAdmin ${env.server_admin}
        ErrorLog "${varDir}/logs/error_log"
        CustomLog "${varDir}/logs/access_log" combined

        <FilesMatch "\.php$">
          SetHandler "proxy:unix:/run/phpfpm/telio-tortay.sock|fcgi://localhost"
        </FilesMatch>

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