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