]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/chloe/integration.nix
Remove webappdirs
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / integration.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
d3452fc5
IB
3 apacheUser = config.services.httpd.Inte.user;
4 apacheGroup = config.services.httpd.Inte.group;
5 ccfg = config.myEnv.websites.chloe.integration;
6 app = pkgs.callPackage ./app {
7 inherit (ccfg) environment;
8 inherit (pkgs.webapps) spip;
9 varDir = "/var/lib/chloe_integration";
f8026b6e 10 };
f8026b6e
IB
11 cfg = config.myServices.websites.chloe.integration;
12in {
13 options.myServices.websites.chloe.integration.enable = lib.mkEnableOption "enable Chloe's website in integration";
14
15 config = lib.mkIf cfg.enable {
d3452fc5 16 services.duplyBackup.profiles.chloe_integration.rootDir = app.varDir;
4c4652aa
IB
17 secrets.keys."websites/chloe/integration" = {
18 user = apacheUser;
19 group = apacheGroup;
20 permissions = "0400";
21 text = ''
22 SetEnv SPIP_CONFIG_DIR "${./config}"
23 SetEnv SPIP_VAR_DIR "${app.varDir}"
24 SetEnv SPIP_SITE "chloe-${app.environment}"
25 SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu"
26 SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu"
27 SetEnv SPIP_LDAP_SEARCH_DN "${ccfg.ldap.dn}"
28 SetEnv SPIP_LDAP_SEARCH_PW "${ccfg.ldap.password}"
29 SetEnv SPIP_LDAP_SEARCH "${ccfg.ldap.filter}"
30 SetEnv SPIP_MYSQL_HOST "${ccfg.mysql.host}"
31 SetEnv SPIP_MYSQL_PORT "${ccfg.mysql.port}"
32 SetEnv SPIP_MYSQL_DB "${ccfg.mysql.database}"
33 SetEnv SPIP_MYSQL_USER "${ccfg.mysql.user}"
34 SetEnv SPIP_MYSQL_PASSWORD "${ccfg.mysql.password}"
35 '';
36 };
d3452fc5
IB
37 systemd.services.phpfpm-chloe_integration.after = lib.mkAfter [ "mysql.service" ];
38 systemd.services.phpfpm-chloe_integration.wants = [ "mysql.service" ];
39 services.phpfpm.pools.chloe_integration = {
5400b9b6
IB
40 user = config.services.httpd.Inte.user;
41 group = config.services.httpd.Inte.group;
d3452fc5
IB
42 settings = {
43 "listen.owner" = apacheUser;
44 "listen.group" = apacheGroup;
45 "php_admin_value[upload_max_filesize]" = "20M";
46 "php_admin_value[post_max_size]" = "20M";
47 # "php_admin_flag[log_errors]" = "on";
48 "php_admin_value[open_basedir]" = "${app.spipConfig}:${./config}:${app}:${app.varDir}:/tmp";
49 "php_admin_value[session.save_path]" = "${app.varDir}/phpSessions";
50 "pm" = "ondemand";
51 "pm.max_children" = "5";
52 "pm.process_idle_timeout" = "60";
53 };
dcac3ec7 54 phpPackage = pkgs.php72;
f40f5b23 55 };
d3452fc5
IB
56 system.activationScripts.chloe_integration = {
57 deps = [ "wrappers" ];
58 text = ''
59 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local
60 install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions
61 '';
62 };
d3452fc5
IB
63 services.websites.env.integration.modules = [ "proxy_fcgi" ];
64 services.websites.env.integration.vhostConfs.chloe_integration = {
0f71cd76 65 certName = "integration";
f8026b6e
IB
66 addToCerts = true;
67 hosts = ["chloe.immae.eu" ];
750fe5a4 68 root = app.webRoot;
5400b9b6 69 extraConfig = [
d3452fc5
IB
70 ''
71 Include ${config.secrets.fullPaths."websites/chloe/integration"}
72
73 RewriteEngine On
74
75 <FilesMatch "\.php$">
76 SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_integration.socket}|fcgi://localhost"
77 </FilesMatch>
78
750fe5a4 79 <Directory ${app.webRoot}>
d3452fc5
IB
80 DirectoryIndex index.php index.htm index.html
81 Options -Indexes +FollowSymLinks +MultiViews +Includes
750fe5a4 82 Include ${app.webRoot}/htaccess.txt
d3452fc5
IB
83
84 AllowOverride AuthConfig FileInfo Limit
85 Require all granted
86 </Directory>
87
750fe5a4 88 <DirectoryMatch "${app.webRoot}/squelettes">
d3452fc5
IB
89 Require all denied
90 </DirectoryMatch>
91
92 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
93 Require all denied
94 </FilesMatch>
95
96 <Location />
97 Use LDAPConnect
98 Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
99 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>"
100 </Location>
101 ''
5400b9b6 102 ];
f8026b6e 103 };
29f8cb85 104 services.websites.env.integration.watchPaths = [
d3452fc5 105 config.secrets.fullPaths."websites/chloe/integration"
17f6eae9 106 ];
f8026b6e
IB
107 };
108}