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