aboutsummaryrefslogtreecommitdiff
path: root/nixops/modules/websites/chloe
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-25 23:15:08 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-01-25 23:15:08 +0100
commit01f21083a897b86bf148f1d2bb9c8edca4d3786a (patch)
tree784f04e9b6ef99a49e572c84e4b7ab40b5eb5fde /nixops/modules/websites/chloe
parentbfe3c9c9df0c5112bc8806483292b55ed0f7e02d (diff)
downloadNix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.tar.gz
Nix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.tar.zst
Nix-01f21083a897b86bf148f1d2bb9c8edca4d3786a.zip
Rename virtual folder to nixops
Fixes https://git.immae.eu/mantisbt/view.php?id=82
Diffstat (limited to 'nixops/modules/websites/chloe')
-rw-r--r--nixops/modules/websites/chloe/chloe.json14
-rw-r--r--nixops/modules/websites/chloe/chloe.nix123
-rw-r--r--nixops/modules/websites/chloe/chloe_config_dev/chmod.php4
-rw-r--r--nixops/modules/websites/chloe/chloe_config_dev/connect.php6
-rw-r--r--nixops/modules/websites/chloe/chloe_config_dev/ldap.php9
-rw-r--r--nixops/modules/websites/chloe/chloe_config_prod/chmod.php4
-rw-r--r--nixops/modules/websites/chloe/chloe_config_prod/connect.php6
-rw-r--r--nixops/modules/websites/chloe/chloe_config_prod/ldap.php9
-rw-r--r--nixops/modules/websites/chloe/default.nix72
-rw-r--r--nixops/modules/websites/chloe/goaccess.conf99
10 files changed, 346 insertions, 0 deletions
diff --git a/nixops/modules/websites/chloe/chloe.json b/nixops/modules/websites/chloe/chloe.json
new file mode 100644
index 0000000..686d751
--- /dev/null
+++ b/nixops/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/nixops/modules/websites/chloe/chloe.nix b/nixops/modules/websites/chloe/chloe.nix
new file mode 100644
index 0000000..355cca7
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe.nix
@@ -0,0 +1,123 @@
1{ stdenv, lib, fetchzip, fetchurl, fetchedGitPrivate, sassc }:
2let
3 chloe = { config }: rec {
4 environment = config.environment;
5 phpFpm = rec {
6 socket = "/var/run/phpfpm/chloe-${environment}.sock";
7 pool = ''
8 listen = ${socket}
9 user = ${apache.user}
10 group = ${apache.group}
11 listen.owner = ${apache.user}
12 listen.group = ${apache.group}
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] = "${../commons/spip/spip_mes_options.php}:${configDir}:${webRoot}:${varDir}:/tmp"
17 php_admin_value[session.save_path] = "${varDir}/phpSessions"
18 env[SPIP_CONFIG_DIR] = "${configDir}"
19 env[SPIP_VAR_DIR] = "${varDir}"
20 env[SPIP_SITE] = "chloe-${environment}"
21 env[SPIP_LDAP_BASE] = "dc=immae,dc=eu"
22 env[SPIP_LDAP_HOST] = "ldaps://ldap.immae.eu"
23 env[SPIP_LDAP_SEARCH_DN] = "${config.ldap.dn}"
24 env[SPIP_LDAP_SEARCH_PW] = "${config.ldap.password}"
25 env[SPIP_LDAP_SEARCH] = "${config.ldap.search}"
26 env[SPIP_MYSQL_HOST] = "db-1.immae.eu"
27 env[SPIP_MYSQL_DB] = "${config.mysql.name}"
28 env[SPIP_MYSQL_USER] = "${config.mysql.user}"
29 env[SPIP_MYSQL_PASSWORD] = "${config.mysql.password}"
30 ${if environment == "dev" then ''
31 pm = ondemand
32 pm.max_children = 5
33 pm.process_idle_timeout = 60
34 '' else ''
35 pm = dynamic
36 pm.max_children = 20
37 pm.start_servers = 2
38 pm.min_spare_servers = 1
39 pm.max_spare_servers = 3
40 ''}'';
41 };
42 apache = {
43 user = "wwwrun";
44 group = "wwwrun";
45 modules = [ "proxy_fcgi" ];
46 vhostConf = ''
47 RewriteEngine On
48 ${if environment == "prod" then ''
49 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
50 '' else ""}
51
52 <FilesMatch "\.php$">
53 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
54 </FilesMatch>
55
56 <Directory ${webRoot}>
57 DirectoryIndex index.php index.htm index.html
58 Options -Indexes +FollowSymLinks +MultiViews +Includes
59 Include ${webRoot}/htaccess.txt
60
61 AllowOverride AuthConfig FileInfo Limit
62 Require all granted
63 </Directory>
64
65 <DirectoryMatch "${webRoot}/squelettes">
66 Require all denied
67 </DirectoryMatch>
68
69 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
70 Require all denied
71 </FilesMatch>
72
73 ${if environment == "dev" then ''
74 <Location />
75 Use LDAPConnect
76 Require ldap-group cn=chloe.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
77 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://osteopathe-cc.fr\"></html>"
78 </Location>
79 '' else ''
80 Use Stats osteopathe-cc.fr
81 ''}
82 '';
83 };
84 activationScript = {
85 deps = [ "wrappers" ];
86 text = ''
87 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} ${varDir}/IMG ${varDir}/tmp ${varDir}/local
88 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
89 '';
90 };
91 configDir = ./chloe_config_ + environment;
92 varDir = "/var/lib/chloe_${environment}";
93 siteDir = stdenv.mkDerivation (fetchedGitPrivate ./chloe.json // rec {
94 buildPhase = ''
95 make
96 '';
97 installPhase = ''
98 cp -a . $out
99 '';
100 buildInputs = [ sassc ];
101 });
102 webRoot = stdenv.mkDerivation rec {
103 name = "chloe-${environment}-spip-${version}";
104 version = "3.2.3";
105 src = fetchzip {
106 url = "https://files.spip.net/spip/archives/SPIP-v${version}.zip";
107 sha256 = "1r1mjvsnrp6mvkgjakvi3x4ms8m8k5mp93micbbg8r99fj7qlfkq";
108 };
109 paches = [ ../commons/spip/spip_ldap_patch.patch ];
110 buildPhase = ''
111 rm -rf IMG local tmp config/remove.txt
112 ln -sf ${../commons/spip/spip_mes_options.php} config/mes_options.php
113 echo "Require all denied" > "config/.htaccess"
114 ln -sf ../../../../../${varDir}/{IMG,local} .
115 '';
116 installPhase = ''
117 cp -a . $out
118 cp -a ${siteDir}/* $out
119 '';
120 };
121 };
122in
123 chloe
diff --git a/nixops/modules/websites/chloe/chloe_config_dev/chmod.php b/nixops/modules/websites/chloe/chloe_config_dev/chmod.php
new file mode 100644
index 0000000..aae16cd
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_dev/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/nixops/modules/websites/chloe/chloe_config_dev/connect.php b/nixops/modules/websites/chloe/chloe_config_dev/connect.php
new file mode 100644
index 0000000..2e4439f
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_dev/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/nixops/modules/websites/chloe/chloe_config_dev/ldap.php b/nixops/modules/websites/chloe/chloe_config_dev/ldap.php
new file mode 100644
index 0000000..825b7ed
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_dev/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/nixops/modules/websites/chloe/chloe_config_prod/chmod.php b/nixops/modules/websites/chloe/chloe_config_prod/chmod.php
new file mode 100644
index 0000000..aae16cd
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_prod/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/nixops/modules/websites/chloe/chloe_config_prod/connect.php b/nixops/modules/websites/chloe/chloe_config_prod/connect.php
new file mode 100644
index 0000000..2e4439f
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_prod/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/nixops/modules/websites/chloe/chloe_config_prod/ldap.php b/nixops/modules/websites/chloe/chloe_config_prod/ldap.php
new file mode 100644
index 0000000..825b7ed
--- /dev/null
+++ b/nixops/modules/websites/chloe/chloe_config_prod/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/nixops/modules/websites/chloe/default.nix b/nixops/modules/websites/chloe/default.nix
new file mode 100644
index 0000000..94cd4be
--- /dev/null
+++ b/nixops/modules/websites/chloe/default.nix
@@ -0,0 +1,72 @@
1{ lib, pkgs, config, myconfig, mylibs, ... }:
2let
3 chloe = pkgs.callPackage ./chloe.nix { inherit (mylibs) fetchedGitPrivate; };
4 chloe_dev = chloe {
5 config = myconfig.env.websites.chloe.integration;
6 };
7 chloe_prod = chloe {
8 config = myconfig.env.websites.chloe.production;
9 };
10
11 cfg = config.services.myWebsites.Chloe;
12in {
13 options.services.myWebsites.Chloe = {
14 production = {
15 enable = lib.mkEnableOption "enable Chloe's website in production";
16 };
17 integration = {
18 enable = lib.mkEnableOption "enable Chloe's website in integration";
19 };
20 };
21
22 imports = [
23 ../commons/stats.nix
24 ];
25
26 config = lib.mkMerge [
27 (lib.mkIf cfg.production.enable {
28 services.myWebsites.commons.stats.enable = true;
29 services.myWebsites.commons.stats.sites = [
30 {
31 name = "osteopathe-cc.fr";
32 conf = ./goaccess.conf;
33 }
34 ];
35
36 security.acme.certs."chloe" = config.services.myCertificates.certConfig // {
37 domain = "osteopathe-cc.fr";
38 extraDomains = {
39 "www.osteopathe-cc.fr" = null;
40 };
41 };
42
43 services.myPhpfpm.poolConfigs.chloe_prod = chloe_prod.phpFpm.pool;
44 services.myPhpfpm.poolPhpConfigs.chloe_prod = ''
45 extension=${pkgs.php}/lib/php/extensions/mysqli.so
46 '';
47 system.activationScripts.chloe_prod = chloe_prod.activationScript;
48 services.myWebsites.production.modules = chloe_prod.apache.modules;
49 services.myWebsites.production.vhostConfs.chloe = {
50 certName = "chloe";
51 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
52 root = chloe_prod.webRoot;
53 extraConfig = [ chloe_prod.apache.vhostConf ];
54 };
55 })
56 (lib.mkIf cfg.integration.enable {
57 security.acme.certs."eldiron".extraDomains."chloe.immae.eu" = null;
58 services.myPhpfpm.poolConfigs.chloe_dev = chloe_dev.phpFpm.pool;
59 services.myPhpfpm.poolPhpConfigs.chloe_dev = ''
60 extension=${pkgs.php}/lib/php/extensions/mysqli.so
61 '';
62 system.activationScripts.chloe_dev = chloe_dev.activationScript;
63 services.myWebsites.integration.modules = chloe_dev.apache.modules;
64 services.myWebsites.integration.vhostConfs.chloe = {
65 certName = "eldiron";
66 hosts = ["chloe.immae.eu" ];
67 root = chloe_dev.webRoot;
68 extraConfig = [ chloe_dev.apache.vhostConf ];
69 };
70 })
71 ];
72}
diff --git a/nixops/modules/websites/chloe/goaccess.conf b/nixops/modules/websites/chloe/goaccess.conf
new file mode 100644
index 0000000..89cff6d
--- /dev/null
+++ b/nixops/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