aboutsummaryrefslogtreecommitdiff
path: root/virtual/modules/websites/chloe
diff options
context:
space:
mode:
Diffstat (limited to 'virtual/modules/websites/chloe')
-rw-r--r--virtual/modules/websites/chloe/chloe.json14
-rw-r--r--virtual/modules/websites/chloe/chloe.nix131
-rw-r--r--virtual/modules/websites/chloe/chloe_config/chmod.php4
-rw-r--r--virtual/modules/websites/chloe/chloe_config/connect.php6
-rw-r--r--virtual/modules/websites/chloe/chloe_config/ldap.php9
-rw-r--r--virtual/modules/websites/chloe/default.nix62
-rw-r--r--virtual/modules/websites/chloe/goaccess.conf99
7 files changed, 325 insertions, 0 deletions
diff --git a/virtual/modules/websites/chloe/chloe.json b/virtual/modules/websites/chloe/chloe.json
new file mode 100644
index 0000000..686d751
--- /dev/null
+++ b/virtual/modules/websites/chloe/chloe.json
@@ -0,0 +1,14 @@
1{
2 "tag": "96fc4eb-master",
3 "meta": {
4 "name": "chloe",
5 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Chloe",
6 "branch": "master"
7 },
8 "git": {
9 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Chloe",
10 "rev": "96fc4eb0099a29b0f9a58fb4eaec4bf14ac65f0a",
11 "sha256": "0mf15j6z86j2smm2k360cmm5djhcjbs9949pznwi57kw97vkm1s3",
12 "fetchSubmodules": true
13 }
14}
diff --git a/virtual/modules/websites/chloe/chloe.nix b/virtual/modules/websites/chloe/chloe.nix
new file mode 100644
index 0000000..126d8e7
--- /dev/null
+++ b/virtual/modules/websites/chloe/chloe.nix
@@ -0,0 +1,131 @@
1{ stdenv, lib, checkEnv, fetchzip, fetchurl, fetchedGitPrivate, sassc }:
2let
3 chloe = { environment ? "dev" }: rec {
4 varPrefix = "CHLOE";
5 envName= lib.strings.toUpper environment;
6 phpFpm = rec {
7 socket = "/var/run/phpfpm/chloe-${environment}.sock";
8 pool =
9 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD";
10 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER";
11 assert checkEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB";
12 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN";
13 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD";
14 assert checkEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH";
15 ''
16 listen = ${socket}
17 user = ${apache.user}
18 group = ${apache.group}
19 listen.owner = ${apache.user}
20 listen.group = ${apache.group}
21 php_admin_value[upload_max_filesize] = 20M
22 php_admin_value[post_max_size] = 20M
23 ;php_admin_flag[log_errors] = on
24 php_admin_value[open_basedir] = "${../commons/spip/spip_mes_options.php}:${configDir}:${webRoot}:${varDir}:/tmp"
25 php_admin_value[session.save_path] = "${varDir}/phpSessions"
26 env[SPIP_CONFIG_DIR] = "${configDir}"
27 env[SPIP_VAR_DIR] = "${varDir}"
28 env[SPIP_SITE] = "chloe-${environment}"
29 env[SPIP_LDAP_BASE] = "dc=immae,dc=eu"
30 env[SPIP_LDAP_HOST] = "ldaps://ldap.immae.eu"
31 env[SPIP_LDAP_SEARCH_DN] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_DN"}"
32 env[SPIP_LDAP_SEARCH_PW] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_PASSWORD"}"
33 env[SPIP_LDAP_SEARCH] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_LDAP_SEARCH"}"
34 env[SPIP_MYSQL_HOST] = "db-1.immae.eu"
35 env[SPIP_MYSQL_DB] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_DB"}"
36 env[SPIP_MYSQL_USER] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_USER"}"
37 env[SPIP_MYSQL_PASSWORD] = "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_MYSQL_PASSWORD"}"
38 ${if environment == "dev" then ''
39 pm = ondemand
40 pm.max_children = 5
41 pm.process_idle_timeout = 60
42 '' else ''
43 pm = dynamic
44 pm.max_children = 20
45 pm.start_servers = 2
46 pm.min_spare_servers = 1
47 pm.max_spare_servers = 3
48 ''}'';
49 };
50 apache = {
51 user = "wwwrun";
52 group = "wwwrun";
53 modules = [ "proxy_fcgi" ];
54 vhostConf = ''
55 RewriteEngine On
56 ${if environment == "prod" then ''
57 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
58 '' else ""}
59
60 <FilesMatch "\.php$">
61 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
62 </FilesMatch>
63
64 <Directory ${webRoot}>
65 DirectoryIndex index.php index.htm index.html
66 Options -Indexes +FollowSymLinks +MultiViews +Includes
67 Include ${webRoot}/htaccess.txt
68
69 AllowOverride AuthConfig FileInfo Limit
70 Require all granted
71 </Directory>
72
73 <DirectoryMatch "${webRoot}/squelettes">
74 Require all denied
75 </DirectoryMatch>
76
77 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
78 Require all denied
79 </FilesMatch>
80
81 ${if environment == "dev" then ''
82 <Location />
83 Use LDAPConnect
84 Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
85 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>"
86 </Location>
87 '' else ''
88 Use Stats osteopathe-cc.fr
89 ''}
90 '';
91 };
92 activationScript = {
93 deps = [ "wrappers" ];
94 text = ''
95 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} ${varDir}/IMG ${varDir}/tmp ${varDir}/local
96 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
97 '';
98 };
99 configDir = ./chloe_config;
100 varDir = "/var/lib/chloe_${environment}";
101 siteDir = stdenv.mkDerivation (fetchedGitPrivate ./chloe.json // rec {
102 buildPhase = ''
103 make
104 '';
105 installPhase = ''
106 cp -a . $out
107 '';
108 buildInputs = [ sassc ];
109 });
110 webRoot = stdenv.mkDerivation rec {
111 name = "chloe-${environment}-spip-${version}";
112 version = "3.2";
113 src = fetchzip {
114 url = "http://files.spip.org/spip/stable/spip-${version}.zip";
115 sha256 = "0cacpxs9nv61i3hzd3nbmplq4mp22s886llhacp3n4923jd6snx5";
116 };
117 paches = [ ../commons/spip/spip_ldap_patch.patch ];
118 buildPhase = ''
119 rm -rf IMG local tmp config/remove.txt
120 ln -sf ${../commons/spip/spip_mes_options.php} config/mes_options.php
121 echo "Require all denied" > "config/.htaccess"
122 ln -sf ../../../../../${varDir}/{IMG,local} .
123 '';
124 installPhase = ''
125 cp -a . $out
126 cp -a ${siteDir}/* $out
127 '';
128 };
129 };
130in
131 chloe
diff --git a/virtual/modules/websites/chloe/chloe_config/chmod.php b/virtual/modules/websites/chloe/chloe_config/chmod.php
new file mode 100644
index 0000000..aae16cd
--- /dev/null
+++ b/virtual/modules/websites/chloe/chloe_config/chmod.php
@@ -0,0 +1,4 @@
1<?php
2if (!defined("_ECRIRE_INC_VERSION")) return;
3if (!defined('_SPIP_CHMOD')) define('_SPIP_CHMOD', 0777);
4?> \ No newline at end of file
diff --git a/virtual/modules/websites/chloe/chloe_config/connect.php b/virtual/modules/websites/chloe/chloe_config/connect.php
new file mode 100644
index 0000000..2e4439f
--- /dev/null
+++ b/virtual/modules/websites/chloe/chloe_config/connect.php
@@ -0,0 +1,6 @@
1<?php
2if (!defined("_ECRIRE_INC_VERSION")) return;
3define('_MYSQL_SET_SQL_MODE',true);
4$GLOBALS['spip_connect_version'] = 0.7;
5spip_connect_db(getenv("SPIP_MYSQL_HOST"),'',getenv("SPIP_MYSQL_USER"),getenv("SPIP_MYSQL_PASSWORD"),getenv("SPIP_MYSQL_DB"),'mysql', 'spip','ldap.php');
6?>
diff --git a/virtual/modules/websites/chloe/chloe_config/ldap.php b/virtual/modules/websites/chloe/chloe_config/ldap.php
new file mode 100644
index 0000000..825b7ed
--- /dev/null
+++ b/virtual/modules/websites/chloe/chloe_config/ldap.php
@@ -0,0 +1,9 @@
1<?php
2if (!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/virtual/modules/websites/chloe/default.nix b/virtual/modules/websites/chloe/default.nix
new file mode 100644
index 0000000..72a9b6f
--- /dev/null
+++ b/virtual/modules/websites/chloe/default.nix
@@ -0,0 +1,62 @@
1{ lib, pkgs, config, mylibs, ... }:
2let
3 chloe = pkgs.callPackage ./chloe.nix { inherit (mylibs) checkEnv fetchedGitPrivate; };
4 chloe_dev = chloe { environment = "dev"; };
5 chloe_prod = chloe { environment = "prod"; };
6
7 cfg = config.services.myWebsites.Chloe;
8in {
9 options.services.myWebsites.Chloe = {
10 production = {
11 enable = lib.mkEnableOption "enable Chloe's website in production";
12 };
13 integration = {
14 enable = lib.mkEnableOption "enable Chloe's website in integration";
15 };
16 };
17
18 imports = [
19 ../commons/stats.nix
20 ];
21
22 config = lib.mkMerge [
23 (lib.mkIf cfg.production.enable {
24 services.myWebsites.commons.stats.enable = true;
25 services.myWebsites.commons.stats.sites = [
26 {
27 name = "osteopathe-cc.fr";
28 conf = ./goaccess.conf;
29 }
30 ];
31
32 security.acme.certs."chloe" = config.services.myCertificates.certConfig // {
33 domain = "osteopathe-cc.fr";
34 extraDomains = {
35 "www.osteopathe-cc.fr" = null;
36 };
37 };
38
39 services.phpfpm.poolConfigs.chloe_prod = chloe_prod.phpFpm.pool;
40 system.activationScripts.chloe_prod = chloe_prod.activationScript;
41 services.myWebsites.production.modules = chloe_prod.apache.modules;
42 services.myWebsites.production.vhostConfs.chloe = {
43 certName = "chloe";
44 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
45 root = chloe_prod.webRoot;
46 extraConfig = [ chloe_prod.apache.vhostConf ];
47 };
48 })
49 (lib.mkIf cfg.integration.enable {
50 security.acme.certs."eldiron".extraDomains."chloe.immae.eu" = null;
51 services.phpfpm.poolConfigs.chloe_dev = chloe_dev.phpFpm.pool;
52 system.activationScripts.chloe_dev = chloe_dev.activationScript;
53 services.myWebsites.integration.modules = chloe_dev.apache.modules;
54 services.myWebsites.integration.vhostConfs.chloe = {
55 certName = "eldiron";
56 hosts = ["chloe.immae.eu" ];
57 root = chloe_dev.webRoot;
58 extraConfig = [ chloe_dev.apache.vhostConf ];
59 };
60 })
61 ];
62}
diff --git a/virtual/modules/websites/chloe/goaccess.conf b/virtual/modules/websites/chloe/goaccess.conf
new file mode 100644
index 0000000..89cff6d
--- /dev/null
+++ b/virtual/modules/websites/chloe/goaccess.conf
@@ -0,0 +1,99 @@
1time-format %H:%M:%S
2date-format %d/%b/%Y
3
4#sur immae.eu
5#log-format %v %h %^[%d:%t %^] "%r" %s %b "%R" "%u" $^
6
7log-format VCOMBINED
8#= %v:%^ %h %^[%d:%t %^] "%r" %s %b "%R" "%u"
9
10html-prefs {"theme":"bright","layout":"vertical"}
11
12exclude-ip 188.165.209.148
13exclude-ip 178.33.252.96
14exclude-ip 2001:41d0:2:9c94::1
15exclude-ip 2001:41d0:2:9c94::
16exclude-ip 176.9.151.89
17exclude-ip 2a01:4f8:160:3445::
18exclude-ip 82.255.56.72
19
20no-query-string true
21
22keep-db-files true
23load-from-disk true
24db-path /var/lib/goaccess/osteopathe-cc.fr
25
26ignore-panel REFERRERS
27ignore-panel KEYPHRASES
28
29static-file .css
30static-file .js
31static-file .jpg
32static-file .png
33static-file .gif
34static-file .ico
35static-file .jpeg
36static-file .pdf
37static-file .csv
38static-file .mpeg
39static-file .mpg
40static-file .swf
41static-file .woff
42static-file .woff2
43static-file .xls
44static-file .xlsx
45static-file .doc
46static-file .docx
47static-file .ppt
48static-file .pptx
49static-file .txt
50static-file .zip
51static-file .ogg
52static-file .mp3
53static-file .mp4
54static-file .exe
55static-file .iso
56static-file .gz
57static-file .rar
58static-file .svg
59static-file .bmp
60static-file .tar
61static-file .tgz
62static-file .tiff
63static-file .tif
64static-file .ttf
65static-file .flv
66#static-file .less
67#static-file .ac3
68#static-file .avi
69#static-file .bz2
70#static-file .class
71#static-file .cue
72#static-file .dae
73#static-file .dat
74#static-file .dts
75#static-file .ejs
76#static-file .eot
77#static-file .eps
78#static-file .img
79#static-file .jar
80#static-file .map
81#static-file .mid
82#static-file .midi
83#static-file .ogv
84#static-file .webm
85#static-file .mkv
86#static-file .odp
87#static-file .ods
88#static-file .odt
89#static-file .otf
90#static-file .pict
91#static-file .pls
92#static-file .ps
93#static-file .qt
94#static-file .rm
95#static-file .svgz
96#static-file .wav
97#static-file .webp
98
99