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