diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-18 16:10:56 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-20 01:51:48 +0200 |
commit | d3452fc59b9839846225fd254926c64a9c71f071 (patch) | |
tree | a98a0958b826ac4b2ab137720edf0195c65dd958 /modules/private/websites/isabelle/iridologie.nix | |
parent | 514f9ec3beec470c4445be690673a0ceab9115b4 (diff) | |
download | Nix-d3452fc59b9839846225fd254926c64a9c71f071.tar.gz Nix-d3452fc59b9839846225fd254926c64a9c71f071.tar.zst Nix-d3452fc59b9839846225fd254926c64a9c71f071.zip |
Refactor websites
Diffstat (limited to 'modules/private/websites/isabelle/iridologie.nix')
-rw-r--r-- | modules/private/websites/isabelle/iridologie.nix | 111 |
1 files changed, 91 insertions, 20 deletions
diff --git a/modules/private/websites/isabelle/iridologie.nix b/modules/private/websites/isabelle/iridologie.nix index ffbf259..560e605 100644 --- a/modules/private/websites/isabelle/iridologie.nix +++ b/modules/private/websites/isabelle/iridologie.nix | |||
@@ -1,50 +1,121 @@ | |||
1 | { lib, pkgs, config, ... }: | 1 | { lib, pkgs, config, ... }: |
2 | let | 2 | let |
3 | iridologie = pkgs.callPackage ./spip_builder.nix { | 3 | icfg = config.myEnv.websites.isabelle.iridologie; |
4 | inherit (pkgs.webapps) iridologie; | 4 | cfg = config.myServices.websites.isabelle.iridologie; |
5 | config = config.myEnv.websites.isabelle.iridologie; | 5 | app = pkgs.callPackage ./iridologie_app { |
6 | apacheUser = config.services.httpd.Prod.user; | 6 | inherit (icfg) environment; |
7 | apacheGroup = config.services.httpd.Prod.group; | 7 | inherit (pkgs.webapps) spip; |
8 | varDir = "/var/lib/isabelle_iridologie"; | ||
8 | }; | 9 | }; |
9 | 10 | ||
10 | cfg = config.myServices.websites.isabelle.iridologie; | 11 | apacheUser = config.services.httpd.Prod.user; |
12 | apacheGroup = config.services.httpd.Prod.group; | ||
13 | webappdir = config.services.websites.webappDirsPaths.isabelle_iridologie; | ||
14 | secretsPath = config.secrets.fullPaths."websites/isabelle/iridologie"; | ||
11 | in { | 15 | in { |
12 | options.myServices.websites.isabelle.iridologie.enable = lib.mkEnableOption "enable Iridologie's website"; | 16 | options.myServices.websites.isabelle.iridologie.enable = lib.mkEnableOption "enable Iridologie's website"; |
13 | 17 | ||
14 | config = lib.mkIf cfg.enable { | 18 | config = lib.mkIf cfg.enable { |
15 | services.duplyBackup.profiles.iridologie_prod.rootDir = iridologie.app.varDir; | 19 | services.duplyBackup.profiles.isabelle_iridologie.rootDir = app.varDir; |
16 | secrets.keys = iridologie.keys; | 20 | secrets.keys = [ |
21 | { | ||
22 | dest = "websites/isabelle/iridologie"; | ||
23 | user = apacheUser; | ||
24 | group = apacheGroup; | ||
25 | permissions = "0400"; | ||
26 | text = '' | ||
27 | SetEnv SPIP_CONFIG_DIR "${./config}" | ||
28 | SetEnv SPIP_VAR_DIR "${app.varDir}" | ||
29 | SetEnv SPIP_SITE "iridologie-${app.environment}" | ||
30 | SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu" | ||
31 | SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu" | ||
32 | SetEnv SPIP_LDAP_SEARCH_DN "${icfg.ldap.dn}" | ||
33 | SetEnv SPIP_LDAP_SEARCH_PW "${icfg.ldap.password}" | ||
34 | SetEnv SPIP_LDAP_SEARCH "${icfg.ldap.filter}" | ||
35 | SetEnv SPIP_MYSQL_HOST "${icfg.mysql.host}" | ||
36 | SetEnv SPIP_MYSQL_PORT "${icfg.mysql.port}" | ||
37 | SetEnv SPIP_MYSQL_DB "${icfg.mysql.database}" | ||
38 | SetEnv SPIP_MYSQL_USER "${icfg.mysql.user}" | ||
39 | SetEnv SPIP_MYSQL_PASSWORD "${icfg.mysql.password}" | ||
40 | ''; | ||
41 | } | ||
42 | ]; | ||
17 | services.webstats.sites = [ { name = "iridologie.icommandeur.org"; } ]; | 43 | services.webstats.sites = [ { name = "iridologie.icommandeur.org"; } ]; |
18 | 44 | ||
19 | systemd.services.phpfpm-iridologie.after = lib.mkAfter iridologie.phpFpm.serviceDeps; | 45 | systemd.services.phpfpm-isabelle_iridologie.after = lib.mkAfter [ "mysql.service" ]; |
20 | systemd.services.phpfpm-iridologie.wants = iridologie.phpFpm.serviceDeps; | 46 | systemd.services.phpfpm-isabelle_iridologie.wants = [ "mysql.service" ]; |
21 | services.phpfpm.pools.iridologie = { | 47 | services.phpfpm.pools.isabelle_iridologie = { |
22 | user = config.services.httpd.Prod.user; | 48 | user = config.services.httpd.Prod.user; |
23 | group = config.services.httpd.Prod.group; | 49 | group = config.services.httpd.Prod.group; |
24 | settings = iridologie.phpFpm.pool; | 50 | settings = { |
51 | "listen.owner" = "${apacheUser}"; | ||
52 | "listen.group" = "${apacheGroup}"; | ||
53 | "php_admin_value[upload_max_filesize]" = "20M"; | ||
54 | "php_admin_value[post_max_size]" = "20M"; | ||
55 | #"php_admin_flag[log_errors]" = "on"; | ||
56 | "php_admin_value[open_basedir]" = "${app.spipConfig}:${./config}:${app}:${app.varDir}:/tmp"; | ||
57 | "php_admin_value[session.save_path]" = "${app.varDir}/phpSessions"; | ||
58 | "pm" = "dynamic"; | ||
59 | "pm.max_children" = "20"; | ||
60 | "pm.start_servers" = "2"; | ||
61 | "pm.min_spare_servers" = "1"; | ||
62 | "pm.max_spare_servers" = "3"; | ||
63 | }; | ||
25 | phpOptions = config.services.phpfpm.phpOptions + '' | 64 | phpOptions = config.services.phpfpm.phpOptions + '' |
26 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | 65 | extension=${pkgs.php}/lib/php/extensions/mysqli.so |
27 | ''; | 66 | ''; |
28 | }; | 67 | }; |
29 | system.activationScripts.iridologie = iridologie.activationScript; | 68 | system.activationScripts.isabelle_iridologie = { |
30 | myServices.websites.webappDirs."${iridologie.apache.webappName}" = iridologie.app.webRoot; | 69 | deps = [ "wrappers" ]; |
31 | services.websites.env.production.modules = iridologie.apache.modules; | 70 | text = '' |
32 | services.websites.env.production.vhostConfs.iridologie = { | 71 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local |
33 | certName = "aten"; | 72 | install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions |
73 | ''; | ||
74 | }; | ||
75 | services.websites.webappDirs.isabelle_iridologie = app.webRoot; | ||
76 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | ||
77 | services.websites.env.production.vhostConfs.isabelle_iridologie = { | ||
78 | certName = "isabelle"; | ||
34 | addToCerts = true; | 79 | addToCerts = true; |
35 | hosts = [ "iridologie.icommandeur.org" "icommandeur.org" "www.icommandeur.org" ]; | 80 | hosts = [ "iridologie.icommandeur.org" "icommandeur.org" "www.icommandeur.org" ]; |
36 | root = iridologie.apache.root; | 81 | root = webappdir; |
37 | extraConfig = [ | 82 | extraConfig = [ |
38 | '' | 83 | '' |
39 | RewriteEngine On | 84 | RewriteEngine On |
40 | RewriteCond "%{HTTP_HOST}" "!^iridologie\.icommandeur\.org$" [NC] | 85 | RewriteCond "%{HTTP_HOST}" "!^iridologie\.icommandeur\.org$" [NC] |
41 | RewriteRule ^(.+)$ https://iridologie.icommandeur.org$1 [R=302,L] | 86 | RewriteRule ^(.+)$ https://iridologie.icommandeur.org$1 [R=302,L] |
87 | |||
88 | Include ${secretsPath} | ||
89 | |||
90 | RewriteEngine On | ||
91 | |||
92 | <FilesMatch "\.php$"> | ||
93 | SetHandler "proxy:unix:${config.services.phpfpm.pools.isabelle_iridologie.socket}|fcgi://localhost" | ||
94 | </FilesMatch> | ||
95 | |||
96 | <Directory ${webappdir}> | ||
97 | DirectoryIndex index.php index.htm index.html | ||
98 | Options -Indexes +FollowSymLinks +MultiViews +Includes | ||
99 | Include ${webappdir}/htaccess.txt | ||
100 | |||
101 | AllowOverride AuthConfig FileInfo Limit | ||
102 | Require all granted | ||
103 | </Directory> | ||
104 | |||
105 | <DirectoryMatch "${webappdir}/squelettes"> | ||
106 | Require all denied | ||
107 | </DirectoryMatch> | ||
108 | |||
109 | <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$"> | ||
110 | Require all denied | ||
111 | </FilesMatch> | ||
112 | |||
113 | Use Stats iridologie.icommandeur.org | ||
42 | '' | 114 | '' |
43 | (iridologie.apache.vhostConf config.services.phpfpm.pools.iridologie.socket) | ||
44 | ]; | 115 | ]; |
45 | }; | 116 | }; |
46 | services.websites.env.production.watchPaths = [ | 117 | services.websites.env.production.watchPaths = [ |
47 | "/var/secrets/webapps/${iridologie.app.environment}-iridologie" | 118 | secretsPath |
48 | ]; | 119 | ]; |
49 | }; | 120 | }; |
50 | } | 121 | } |