diff options
Diffstat (limited to 'modules/private/websites/chloe')
-rw-r--r-- | modules/private/websites/chloe/builder.nix | 103 | ||||
-rw-r--r-- | modules/private/websites/chloe/config/chmod.php | 4 | ||||
-rw-r--r-- | modules/private/websites/chloe/config/connect.php | 15 | ||||
-rw-r--r-- | modules/private/websites/chloe/config/ldap.php | 9 | ||||
-rw-r--r-- | modules/private/websites/chloe/integration.nix | 35 | ||||
-rw-r--r-- | modules/private/websites/chloe/production.nix | 37 |
6 files changed, 203 insertions, 0 deletions
diff --git a/modules/private/websites/chloe/builder.nix b/modules/private/websites/chloe/builder.nix new file mode 100644 index 0000000..7b72b97 --- /dev/null +++ b/modules/private/websites/chloe/builder.nix | |||
@@ -0,0 +1,103 @@ | |||
1 | { apacheUser, apacheGroup, chloe, config }: | ||
2 | rec { | ||
3 | app = chloe.override { inherit (config) environment; }; | ||
4 | phpFpm = rec { | ||
5 | serviceDeps = [ "mysql.service" ]; | ||
6 | socket = "/var/run/phpfpm/chloe-${app.environment}.sock"; | ||
7 | pool = '' | ||
8 | listen = ${socket} | ||
9 | user = ${apacheUser} | ||
10 | group = ${apacheGroup} | ||
11 | listen.owner = ${apacheUser} | ||
12 | listen.group = ${apacheGroup} | ||
13 | php_admin_value[upload_max_filesize] = 20M | ||
14 | php_admin_value[post_max_size] = 20M | ||
15 | ;php_admin_flag[log_errors] = on | ||
16 | php_admin_value[open_basedir] = "${app.spipConfig}:${configDir}:${app}:${app.varDir}:/tmp" | ||
17 | php_admin_value[session.save_path] = "${app.varDir}/phpSessions" | ||
18 | ${if app.environment == "dev" then '' | ||
19 | pm = ondemand | ||
20 | pm.max_children = 5 | ||
21 | pm.process_idle_timeout = 60 | ||
22 | '' else '' | ||
23 | pm = dynamic | ||
24 | pm.max_children = 20 | ||
25 | pm.start_servers = 2 | ||
26 | pm.min_spare_servers = 1 | ||
27 | pm.max_spare_servers = 3 | ||
28 | ''}''; | ||
29 | }; | ||
30 | keys = [{ | ||
31 | dest = "webapps/${app.environment}-chloe"; | ||
32 | user = apacheUser; | ||
33 | group = apacheGroup; | ||
34 | permissions = "0400"; | ||
35 | text = '' | ||
36 | SetEnv SPIP_CONFIG_DIR "${configDir}" | ||
37 | SetEnv SPIP_VAR_DIR "${app.varDir}" | ||
38 | SetEnv SPIP_SITE "chloe-${app.environment}" | ||
39 | SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu" | ||
40 | SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu" | ||
41 | SetEnv SPIP_LDAP_SEARCH_DN "${config.ldap.dn}" | ||
42 | SetEnv SPIP_LDAP_SEARCH_PW "${config.ldap.password}" | ||
43 | SetEnv SPIP_LDAP_SEARCH "${config.ldap.search}" | ||
44 | SetEnv SPIP_MYSQL_HOST "${config.mysql.host}" | ||
45 | SetEnv SPIP_MYSQL_PORT "${config.mysql.port}" | ||
46 | SetEnv SPIP_MYSQL_DB "${config.mysql.name}" | ||
47 | SetEnv SPIP_MYSQL_USER "${config.mysql.user}" | ||
48 | SetEnv SPIP_MYSQL_PASSWORD "${config.mysql.password}" | ||
49 | ''; | ||
50 | }]; | ||
51 | apache = rec { | ||
52 | modules = [ "proxy_fcgi" ]; | ||
53 | webappName = "chloe_${app.environment}"; | ||
54 | root = "/run/current-system/webapps/${webappName}"; | ||
55 | vhostConf = '' | ||
56 | Include /var/secrets/webapps/${app.environment}-chloe | ||
57 | |||
58 | RewriteEngine On | ||
59 | ${if app.environment == "prod" then '' | ||
60 | RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1 | ||
61 | '' else ""} | ||
62 | |||
63 | <FilesMatch "\.php$"> | ||
64 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | ||
65 | </FilesMatch> | ||
66 | |||
67 | <Directory ${root}> | ||
68 | DirectoryIndex index.php index.htm index.html | ||
69 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
70 | Include ${root}/htaccess.txt | ||
71 | |||
72 | AllowOverride AuthConfig FileInfo Limit | ||
73 | Require all granted | ||
74 | </Directory> | ||
75 | |||
76 | <DirectoryMatch "${root}/squelettes"> | ||
77 | Require all denied | ||
78 | </DirectoryMatch> | ||
79 | |||
80 | <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$"> | ||
81 | Require all denied | ||
82 | </FilesMatch> | ||
83 | |||
84 | ${if app.environment == "dev" then '' | ||
85 | <Location /> | ||
86 | Use LDAPConnect | ||
87 | Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
88 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>" | ||
89 | </Location> | ||
90 | '' else '' | ||
91 | Use Stats osteopathe-cc.fr | ||
92 | ''} | ||
93 | ''; | ||
94 | }; | ||
95 | activationScript = { | ||
96 | deps = [ "wrappers" ]; | ||
97 | text = '' | ||
98 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local | ||
99 | install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions | ||
100 | ''; | ||
101 | }; | ||
102 | configDir = ./config; | ||
103 | } | ||
diff --git a/modules/private/websites/chloe/config/chmod.php b/modules/private/websites/chloe/config/chmod.php new file mode 100644 index 0000000..aae16cd --- /dev/null +++ b/modules/private/websites/chloe/config/chmod.php | |||
@@ -0,0 +1,4 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777); | ||
4 | ?> \ No newline at end of file | ||
diff --git a/modules/private/websites/chloe/config/connect.php b/modules/private/websites/chloe/config/connect.php new file mode 100644 index 0000000..18b0933 --- /dev/null +++ b/modules/private/websites/chloe/config/connect.php | |||
@@ -0,0 +1,15 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | define('_MYSQL_SET_SQL_MODE',true); | ||
4 | $GLOBALS['spip_connect_version'] = 0.7; | ||
5 | spip_connect_db( | ||
6 | getenv("SPIP_MYSQL_HOST"), | ||
7 | getenv("SPIP_MYSQL_PORT"), | ||
8 | getenv("SPIP_MYSQL_USER"), | ||
9 | getenv("SPIP_MYSQL_PASSWORD"), | ||
10 | getenv("SPIP_MYSQL_DB"), | ||
11 | 'mysql', | ||
12 | 'spip', | ||
13 | 'ldap.php' | ||
14 | ); | ||
15 | ?> | ||
diff --git a/modules/private/websites/chloe/config/ldap.php b/modules/private/websites/chloe/config/ldap.php new file mode 100644 index 0000000..825b7ed --- /dev/null +++ b/modules/private/websites/chloe/config/ldap.php | |||
@@ -0,0 +1,9 @@ | |||
1 | <?php | ||
2 | if (!defined("_ECRIRE_INC_VERSION")) return; | ||
3 | $GLOBALS['ldap_base'] = getenv("SPIP_LDAP_BASE"); | ||
4 | $GLOBALS['ldap_link'] = @ldap_connect(getenv("SPIP_LDAP_HOST")); | ||
5 | @ldap_set_option($GLOBALS['ldap_link'],LDAP_OPT_PROTOCOL_VERSION,'3'); | ||
6 | @ldap_bind($GLOBALS['ldap_link'],getenv("SPIP_LDAP_SEARCH_DN"), getenv("SPIP_LDAP_SEARCH_PW")); | ||
7 | $GLOBALS['ldap_champs'] = array('login' => array('sAMAccountName','uid','login','userid','cn','sn'),'nom' => 'cn','email' => 'mail','bio' => 'description',); | ||
8 | $GLOBALS['ldap_search'] = getenv("SPIP_LDAP_SEARCH"); | ||
9 | ?> | ||
diff --git a/modules/private/websites/chloe/integration.nix b/modules/private/websites/chloe/integration.nix new file mode 100644 index 0000000..458e414 --- /dev/null +++ b/modules/private/websites/chloe/integration.nix | |||
@@ -0,0 +1,35 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | ||
2 | let | ||
3 | chloe = pkgs.callPackage ./builder.nix { | ||
4 | inherit (pkgs.webapps) chloe; | ||
5 | config = myconfig.env.websites.chloe.integration; | ||
6 | apacheUser = config.services.httpd.Inte.user; | ||
7 | apacheGroup = config.services.httpd.Inte.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.chloe.integration; | ||
11 | in { | ||
12 | options.myServices.websites.chloe.integration.enable = lib.mkEnableOption "enable Chloe's website in integration"; | ||
13 | |||
14 | config = lib.mkIf cfg.enable { | ||
15 | secrets.keys = chloe.keys; | ||
16 | services.myPhpfpm.serviceDependencies.chloe_dev = chloe.phpFpm.serviceDeps; | ||
17 | services.myPhpfpm.poolConfigs.chloe_dev = chloe.phpFpm.pool; | ||
18 | services.myPhpfpm.poolPhpConfigs.chloe_dev = '' | ||
19 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | ||
20 | ''; | ||
21 | system.activationScripts.chloe_dev = chloe.activationScript; | ||
22 | system.extraSystemBuilderCmds = '' | ||
23 | mkdir -p $out/webapps | ||
24 | ln -s ${chloe.app.webRoot} $out/webapps/${chloe.apache.webappName} | ||
25 | ''; | ||
26 | services.websites.integration.modules = chloe.apache.modules; | ||
27 | services.websites.integration.vhostConfs.chloe = { | ||
28 | certName = "eldiron"; | ||
29 | addToCerts = true; | ||
30 | hosts = ["chloe.immae.eu" ]; | ||
31 | root = chloe.apache.root; | ||
32 | extraConfig = [ chloe.apache.vhostConf ]; | ||
33 | }; | ||
34 | }; | ||
35 | } | ||
diff --git a/modules/private/websites/chloe/production.nix b/modules/private/websites/chloe/production.nix new file mode 100644 index 0000000..0eafebd --- /dev/null +++ b/modules/private/websites/chloe/production.nix | |||
@@ -0,0 +1,37 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | ||
2 | let | ||
3 | chloe = pkgs.callPackage ./builder.nix { | ||
4 | inherit (pkgs.webapps) chloe; | ||
5 | config = myconfig.env.websites.chloe.production; | ||
6 | apacheUser = config.services.httpd.Prod.user; | ||
7 | apacheGroup = config.services.httpd.Prod.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.chloe.production; | ||
11 | in { | ||
12 | options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production"; | ||
13 | |||
14 | config = lib.mkIf cfg.enable { | ||
15 | secrets.keys = chloe.keys; | ||
16 | services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ]; | ||
17 | |||
18 | services.myPhpfpm.serviceDependencies.chloe_prod = chloe.phpFpm.serviceDeps; | ||
19 | services.myPhpfpm.poolConfigs.chloe_prod = chloe.phpFpm.pool; | ||
20 | services.myPhpfpm.poolPhpConfigs.chloe_prod = '' | ||
21 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | ||
22 | ''; | ||
23 | system.activationScripts.chloe_prod = chloe.activationScript; | ||
24 | system.extraSystemBuilderCmds = '' | ||
25 | mkdir -p $out/webapps | ||
26 | ln -s ${chloe.app.webRoot} $out/webapps/${chloe.apache.webappName} | ||
27 | ''; | ||
28 | services.websites.production.modules = chloe.apache.modules; | ||
29 | services.websites.production.vhostConfs.chloe = { | ||
30 | certName = "chloe"; | ||
31 | certMainHost = "osteopathe-cc.fr"; | ||
32 | hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ]; | ||
33 | root = chloe.apache.root; | ||
34 | extraConfig = [ chloe.apache.vhostConf ]; | ||
35 | }; | ||
36 | }; | ||
37 | } | ||