]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | apacheUser = config.services.httpd.Inte.user; | |
4 | apacheGroup = config.services.httpd.Inte.group; | |
5 | ccfg = config.myEnv.websites.chloe.integration; | |
6 | webRoot = "/var/lib/ftp/immae/chloe"; | |
7 | varDir = "/var/lib/ftp/immae/chloe_var"; | |
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 { | |
13 | secrets.keys."websites/chloe/integration" = { | |
14 | user = apacheUser; | |
15 | group = apacheGroup; | |
16 | permissions = "0400"; | |
17 | text = '' | |
18 | SetEnv SPIP_CONFIG_DIR "${./config}" | |
19 | SetEnv SPIP_VAR_DIR "${varDir}" | |
20 | SetEnv SPIP_SITE "chloe-dev" | |
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 | }; | |
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 = { | |
36 | user = config.services.httpd.Inte.user; | |
37 | group = config.services.httpd.Inte.group; | |
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"; | |
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"; | |
46 | "pm" = "ondemand"; | |
47 | "pm.max_children" = "5"; | |
48 | "pm.process_idle_timeout" = "60"; | |
49 | }; | |
50 | phpPackage = pkgs.php72; | |
51 | }; | |
52 | system.activationScripts.chloe_integration = { | |
53 | deps = [ "wrappers" ]; | |
54 | text = '' | |
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 | |
57 | ''; | |
58 | }; | |
59 | services.websites.env.integration.modules = [ "proxy_fcgi" ]; | |
60 | services.websites.env.integration.vhostConfs.chloe_integration = { | |
61 | certName = "integration"; | |
62 | addToCerts = true; | |
63 | hosts = ["test.chc.immae.dev" ]; | |
64 | root = webRoot; | |
65 | extraConfig = [ | |
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 | ||
75 | <Directory ${webRoot}> | |
76 | DirectoryIndex index.php index.htm index.html | |
77 | Options -Indexes +FollowSymLinks +MultiViews +Includes | |
78 | Include ${webRoot}/htaccess.txt | |
79 | ||
80 | AllowOverride AuthConfig FileInfo Limit | |
81 | Require all granted | |
82 | </Directory> | |
83 | ||
84 | <DirectoryMatch "${webRoot}/squelettes"> | |
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 | |
94 | Require ldap-group cn=chc.immae.dev,cn=httpd,ou=services,dc=immae,dc=eu | |
95 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>" | |
96 | </Location> | |
97 | '' | |
98 | ]; | |
99 | }; | |
100 | services.websites.env.integration.watchPaths = [ | |
101 | config.secrets.fullPaths."websites/chloe/integration" | |
102 | ]; | |
103 | }; | |
104 | } |