aboutsummaryrefslogtreecommitdiff
path: root/virtual/modules/websites/aten
diff options
context:
space:
mode:
Diffstat (limited to 'virtual/modules/websites/aten')
-rw-r--r--virtual/modules/websites/aten/aten.json14
-rw-r--r--virtual/modules/websites/aten/aten.nix126
-rw-r--r--virtual/modules/websites/aten/default.nix64
-rw-r--r--virtual/modules/websites/aten/goaccess.conf99
4 files changed, 303 insertions, 0 deletions
diff --git a/virtual/modules/websites/aten/aten.json b/virtual/modules/websites/aten/aten.json
new file mode 100644
index 0000000..53569b6
--- /dev/null
+++ b/virtual/modules/websites/aten/aten.json
@@ -0,0 +1,14 @@
1{
2 "tag": "b99537f-master",
3 "meta": {
4 "name": "aten",
5 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Aten",
6 "branch": "master"
7 },
8 "git": {
9 "url": "gitolite@git.immae.eu:perso/Immae/Sites/Aten",
10 "rev": "b99537fdad41291afb4f1bb8b2e2aa4081c71fae",
11 "sha256": "15mlyik6zivxwry6zc906bqnivxhby27yr8kj4lg5n68pvb877dn",
12 "fetchSubmodules": true
13 }
14}
diff --git a/virtual/modules/websites/aten/aten.nix b/virtual/modules/websites/aten/aten.nix
new file mode 100644
index 0000000..d67f7b7
--- /dev/null
+++ b/virtual/modules/websites/aten/aten.nix
@@ -0,0 +1,126 @@
1{ lib, checkEnv, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, yarn }:
2let
3 aten = { environment ? "dev" }: rec {
4 varPrefix = "ATEN";
5 varDir = "/var/lib/aten_${environment}";
6 envName= lib.strings.toUpper environment;
7 phpFpm = rec {
8 socket = "/var/run/phpfpm/aten-${environment}.sock";
9 pool = ''
10 listen = ${socket}
11 user = ${apache.user}
12 group = ${apache.group}
13 listen.owner = ${apache.user}
14 listen.group = ${apache.group}
15 php_admin_value[upload_max_filesize] = 20M
16 php_admin_value[post_max_size] = 20M
17 ;php_admin_flag[log_errors] = on
18 php_admin_value[open_basedir] = "${webappDir}:${varDir}:/tmp"
19 php_admin_value[session.save_path] = "${varDir}/phpSessions"
20 ${if environment == "dev" then ''
21 pm = ondemand
22 pm.max_children = 5
23 pm.process_idle_timeout = 60
24 env[SYMFONY_DEBUG_MODE] = "yes"
25 '' else ''
26 pm = dynamic
27 pm.max_children = 20
28 pm.start_servers = 2
29 pm.min_spare_servers = 1
30 pm.max_spare_servers = 3
31 ''}'';
32 };
33 apache = {
34 user = "wwwrun";
35 group = "wwwrun";
36 modules = [ "proxy_fcgi" ];
37 vhostConf =
38 assert checkEnv "NIXOPS_${varPrefix}_${envName}_SECRET";
39 assert checkEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL";
40 ''
41 <FilesMatch "\.php$">
42 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
43 </FilesMatch>
44
45 SetEnv APP_ENV "${environment}"
46 SetEnv APP_SECRET "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}
47 SetEnv DATABASE_URL "${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}
48
49 ${if environment == "dev" then ''
50 <Location />
51 Use LDAPConnect
52 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
53 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
54 </Location>
55
56 <Location /backend>
57 Use LDAPConnect
58 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
59 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
60 </Location>
61 '' else ''
62 Use Stats aten.pro
63
64 <Location /backend>
65 Use LDAPConnect
66 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
67 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
68 </Location>
69 ''}
70
71 <Directory ${webRoot}>
72 Options Indexes FollowSymLinks MultiViews Includes
73 AllowOverride All
74 Require all granted
75 DirectoryIndex index.php
76 FallbackResource /index.php
77 </Directory>
78 '';
79 };
80 activationScript = {
81 deps = [ "wrappers" ];
82 text = ''
83 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
84 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
85 if [ ! -f "${varDir}/currentWebappDir" -o \
86 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
87 pushd ${webappDir} > /dev/null
88 $wrapperDir/sudo -u wwwrun APP_ENV=${environment} ./bin/console --env=${environment} cache:clear --no-warmup
89 popd > /dev/null
90 echo -n "${webappDir}" > ${varDir}/currentWebappDir
91 fi
92 '';
93 };
94 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./aten.json // rec {
95 # FIXME: can we do better than symlink?
96 # FIXME: initial sync
97 # FIXME: backup
98 # FIXME: usage statistics
99 buildPhase = ''
100 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
101 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
102 export APP_ENV="${environment}"
103 export DATABASE_URL="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_PSQL_URL"}"
104 export APP_SECRET="${builtins.getEnv "NIXOPS_${varPrefix}_${envName}_SECRET"}"
105
106 ${if environment == "dev" then ''
107 composer install
108 '' else ''
109 SYMFONY_ENV=prod composer install --no-dev
110 ''}
111 yarn install
112 yarn run encore production
113 rm -rf var
114 ln -sf ../../../../../${varDir} var
115 '';
116 installPhase = ''
117 cp -a . $out
118 '';
119 buildInputs = [
120 php git cacert phpPackages.composer yarn
121 ];
122 });
123 webRoot = "${webappDir}/public";
124 };
125in
126 aten
diff --git a/virtual/modules/websites/aten/default.nix b/virtual/modules/websites/aten/default.nix
new file mode 100644
index 0000000..d9db75c
--- /dev/null
+++ b/virtual/modules/websites/aten/default.nix
@@ -0,0 +1,64 @@
1{ lib, pkgs, config, mylibs, ... }:
2let
3 aten = pkgs.callPackage ./aten.nix { inherit (mylibs) checkEnv fetchedGitPrivate; };
4 aten_dev = aten { environment = "dev"; };
5 aten_prod = aten { environment = "prod"; };
6
7 cfg = config.services.myWebsites.Aten;
8in {
9 options.services.myWebsites.Aten = {
10 production = {
11 enable = lib.mkEnableOption "enable Aten's website in production";
12 };
13 integration = {
14 enable = lib.mkEnableOption "enable Aten'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 = "aten.pro";
28 conf = ./goaccess.conf;
29 }
30 ];
31
32 security.acme.certs."aten" = config.services.myCertificates.certConfig // {
33 domain = "aten.pro";
34 extraDomains = {
35 "www.aten.pro" = null;
36 };
37 };
38
39 services.phpfpm.poolConfigs.aten_prod = aten_prod.phpFpm.pool;
40 system.activationScripts.aten_prod = aten_prod.activationScript;
41 services.myWebsites.apacheConfig.aten_prod.modules = aten_prod.apache.modules;
42 services.myWebsites.production.modules = aten_prod.apache.modules;
43 services.myWebsites.production.vhostConfs.aten = {
44 certName = "aten";
45 hosts = [ "aten.pro" "www.aten.pro" ];
46 root = aten_prod.webRoot;
47 extraConfig = [ aten_prod.apache.vhostConf ];
48 };
49 })
50 (lib.mkIf cfg.integration.enable {
51 security.acme.certs."eldiron".extraDomains."dev.aten.pro" = null;
52 services.phpfpm.poolConfigs.aten_dev = aten_dev.phpFpm.pool;
53 system.activationScripts.aten_dev = aten_dev.activationScript;
54 services.myWebsites.integration.modules = aten_dev.apache.modules;
55 services.myWebsites.integration.vhostConfs.aten = {
56 certName = "eldiron";
57 hosts = [ "dev.aten.pro" ];
58 root = aten_dev.webRoot;
59 extraConfig = [ aten_dev.apache.vhostConf ];
60 };
61 })
62 ];
63}
64
diff --git a/virtual/modules/websites/aten/goaccess.conf b/virtual/modules/websites/aten/goaccess.conf
new file mode 100644
index 0000000..07cce57
--- /dev/null
+++ b/virtual/modules/websites/aten/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/aten.pro
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