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