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