]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/chloe/production.nix
Remove overlay that overrides the php version
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
d3452fc5
IB
3 apacheUser = config.services.httpd.Prod.user;
4 apacheGroup = config.services.httpd.Prod.group;
5 ccfg = config.myEnv.websites.chloe.production;
6 app = pkgs.callPackage ./app {
7 inherit (ccfg) environment;
8 inherit (pkgs.webapps) spip;
9 varDir = "/var/lib/chloe_production";
f8026b6e 10 };
f8026b6e 11 cfg = config.myServices.websites.chloe.production;
d3452fc5 12 webappdir = config.services.websites.webappDirsPaths.chloe_production;
f8026b6e
IB
13in {
14 options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production";
15
16 config = lib.mkIf cfg.enable {
d3452fc5
IB
17 services.duplyBackup.profiles.chloe_production.rootDir = app.varDir;
18 secrets.keys = [
19 {
20 dest = "websites/chloe/production";
21 user = apacheUser;
22 group = apacheGroup;
23 permissions = "0400";
24 text = ''
25 SetEnv SPIP_CONFIG_DIR "${./config}"
26 SetEnv SPIP_VAR_DIR "${app.varDir}"
27 SetEnv SPIP_SITE "chloe-${app.environment}"
28 SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu"
29 SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu"
30 SetEnv SPIP_LDAP_SEARCH_DN "${ccfg.ldap.dn}"
31 SetEnv SPIP_LDAP_SEARCH_PW "${ccfg.ldap.password}"
32 SetEnv SPIP_LDAP_SEARCH "${ccfg.ldap.filter}"
33 SetEnv SPIP_MYSQL_HOST "${ccfg.mysql.host}"
34 SetEnv SPIP_MYSQL_PORT "${ccfg.mysql.port}"
35 SetEnv SPIP_MYSQL_DB "${ccfg.mysql.database}"
36 SetEnv SPIP_MYSQL_USER "${ccfg.mysql.user}"
37 SetEnv SPIP_MYSQL_PASSWORD "${ccfg.mysql.password}"
38 '';
39 }
40 ];
f8026b6e
IB
41 services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
42
d3452fc5
IB
43 systemd.services.phpfpm-chloe_production.after = lib.mkAfter [ "mysql.service" ];
44 systemd.services.phpfpm-chloe_production.wants = [ "mysql.service" ];
45 services.phpfpm.pools.chloe_production = {
5400b9b6
IB
46 user = config.services.httpd.Prod.user;
47 group = config.services.httpd.Prod.group;
d3452fc5
IB
48 settings = {
49 "listen.owner" = apacheUser;
50 "listen.group" = apacheGroup;
51 "php_admin_value[upload_max_filesize]" = "20M";
52 "php_admin_value[post_max_size]" = "20M";
53 # "php_admin_flag[log_errors]" = "on";
54 "php_admin_value[open_basedir]" = "${app.spipConfig}:${./config}:${app}:${app.varDir}:/tmp";
55 "php_admin_value[session.save_path]" = "${app.varDir}/phpSessions";
56 "pm" = "dynamic";
57 "pm.max_children" = "20";
58 "pm.start_servers" = "2";
59 "pm.min_spare_servers" = "1";
60 "pm.max_spare_servers" = "3";
61 };
f40f5b23 62 phpOptions = config.services.phpfpm.phpOptions + ''
dcac3ec7 63 extension=${pkgs.php72}/lib/php/extensions/mysqli.so
f8026b6e 64 '';
dcac3ec7 65 phpPackage = pkgs.php72;
f40f5b23 66 };
d3452fc5
IB
67 system.activationScripts.chloe_production = {
68 deps = [ "wrappers" ];
69 text = ''
70 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local
71 install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions
72 '';
73 };
74 services.websites.webappDirs.chloe_production = app.webRoot;
75 services.websites.env.production.modules = [ "proxy_fcgi" ];
29f8cb85 76 services.websites.env.production.vhostConfs.chloe = {
f8026b6e
IB
77 certName = "chloe";
78 certMainHost = "osteopathe-cc.fr";
79 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
d3452fc5 80 root = webappdir;
33b5010f
IB
81 extraConfig = [
82 ''
d3452fc5
IB
83 Use Stats osteopathe-cc.fr
84
33b5010f
IB
85 RewriteEngine On
86 RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC]
87 RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L]
d3452fc5
IB
88
89 Include ${config.secrets.fullPaths."websites/chloe/production"}
90
91 RewriteEngine On
92 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
93
94 <FilesMatch "\.php$">
95 SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_production.socket}|fcgi://localhost"
96 </FilesMatch>
97
98 <Directory ${webappdir}>
99 DirectoryIndex index.php index.htm index.html
100 Options -Indexes +FollowSymLinks +MultiViews +Includes
101 Include ${webappdir}/htaccess.txt
102
103 AllowOverride AuthConfig FileInfo Limit
104 Require all granted
105 </Directory>
106
107 <DirectoryMatch "${webappdir}/squelettes">
108 Require all denied
109 </DirectoryMatch>
110
111 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
112 Require all denied
113 </FilesMatch>
33b5010f 114 ''
33b5010f 115 ];
f8026b6e 116 };
29f8cb85 117 services.websites.env.production.watchPaths = [
d3452fc5 118 config.secrets.fullPaths."websites/chloe/production"
17f6eae9 119 ];
f8026b6e
IB
120 };
121}