]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/leila/production.nix
Migrate php sessions to redis
[perso/Immae/Config/Nix.git] / modules / private / websites / leila / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.leila.production;
4 varDir = "/var/lib/ftp/leila";
5 apacheUser = config.services.httpd.Prod.user;
6 apacheGroup = config.services.httpd.Prod.group;
7 in {
8 options.myServices.websites.leila.production.enable = lib.mkEnableOption "enable Leila's websites in production";
9
10 config = lib.mkIf cfg.enable {
11 services.phpfpm.pools.leila = {
12 user = apacheUser;
13 group = apacheGroup;
14 settings = {
15 "listen.owner" = apacheUser;
16 "listen.group" = apacheGroup;
17
18 "pm" = "dynamic";
19 "pm.max_children" = "20";
20 "pm.start_servers" = "2";
21 "pm.min_spare_servers" = "1";
22 "pm.max_spare_servers" = "3";
23
24 "php_admin_value[session.save_handler]" = "redis";
25 "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=Leila:production:'";
26 "php_admin_value[open_basedir]" = "${varDir}:/tmp";
27 "php_admin_value[max_execution_time]" = "1800";
28 };
29 phpOptions = config.services.phpfpm.phpOptions + ''
30 disable_functions = "mail"
31 '';
32 phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [ all.imagick all.redis ]);
33 phpEnv = {
34 PATH = lib.makeBinPath [ pkgs.imagemagick ];
35 };
36 };
37
38 services.webstats.sites = [
39 { name = "leila.bouya.org"; }
40 { name = "chorale.leila.bouya.org"; }
41 { name = "syrwennecreation.bouya.org"; }
42 ];
43
44 services.websites.env.production.modules = [ "proxy_fcgi" ];
45 services.websites.env.production.vhostConfs.leila_chorale = {
46 certName = "leila";
47 addToCerts = true;
48 hosts = [ "chorale.leila.bouya.org" "chorale-vocanta.fr.nf" "www.chorale-vocanta.fr.nf" ];
49 root = "${varDir}/Chorale";
50 extraConfig = [
51 ''
52 Use Stats chorale.leila.bouya.org
53 <Directory ${varDir}/Chorale>
54 DirectoryIndex index.php index.htm index.html
55 Options Indexes FollowSymLinks MultiViews Includes
56 AllowOverride None
57
58 Use LDAPConnect
59 Require ldap-group cn=chorale.leila.bouya.org,cn=httpd,ou=services,dc=immae,dc=eu
60
61 <FilesMatch "\.php$">
62 SetHandler "proxy:unix:${config.services.phpfpm.pools.leila.socket}|fcgi://localhost"
63 </FilesMatch>
64 </Directory>
65 ''
66 ];
67 };
68 services.websites.env.production.vhostConfs.leila_syrwenne = {
69 certName = "leila";
70 addToCerts = true;
71 hosts = [ "syrwennecreation.bouya.org" ];
72 root = "${varDir}/Syrwennecreation";
73 extraConfig = [
74 ''
75 Use Stats syrwennecreation.bouya.org
76 <Directory ${varDir}/Syrwennecreation>
77 DirectoryIndex index.php index.htm index.html
78 Options Indexes FollowSymLinks MultiViews Includes
79 AllowOverride None
80
81 <FilesMatch "\.php$">
82 SetHandler "proxy:unix:${config.services.phpfpm.pools.leila.socket}|fcgi://localhost"
83 </FilesMatch>
84 </Directory>
85 ''
86 ];
87 };
88 services.websites.env.production.vhostConfs.leila = {
89 certName = "leila";
90 certMainHost = "leila.bouya.org";
91 hosts = [ "leila.bouya.org" ];
92 root = varDir;
93 extraConfig = [
94 ''
95 Use Stats leila.bouya.org
96 <Directory ${varDir}/Chorale>
97 DirectoryIndex index.htm index.html
98 Options Indexes FollowSymLinks MultiViews Includes
99 AllowOverride None
100
101 Use LDAPConnect
102 Require ldap-group cn=chorale.leila.bouya.org,cn=httpd,ou=services,dc=immae,dc=eu
103
104 <FilesMatch "\.php$">
105 SetHandler "proxy:unix:${config.services.phpfpm.pools.leila.socket}|fcgi://localhost"
106 </FilesMatch>
107 </Directory>
108 <Directory ${varDir}>
109 DirectoryIndex index.htm index.html
110 Options Indexes FollowSymLinks MultiViews Includes
111 AllowOverride None
112 Require all granted
113 </Directory>
114 ''
115 ];
116 };
117 };
118 }