]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/chloe/production.nix
Remove duply-backup
[perso/Immae/Config/Nix.git] / modules / private / websites / chloe / production.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
d3452fc5
IB
3 apacheUser = config.services.httpd.Prod.user;
4 apacheGroup = config.services.httpd.Prod.group;
5 ccfg = config.myEnv.websites.chloe.production;
6 app = pkgs.callPackage ./app {
7 inherit (ccfg) environment;
8 inherit (pkgs.webapps) spip;
9 varDir = "/var/lib/chloe_production";
f8026b6e 10 };
f8026b6e
IB
11 cfg = config.myServices.websites.chloe.production;
12in {
13 options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production";
14
15 config = lib.mkIf cfg.enable {
4c4652aa
IB
16 secrets.keys."websites/chloe/production" = {
17 user = apacheUser;
18 group = apacheGroup;
19 permissions = "0400";
20 text = ''
21 SetEnv SPIP_CONFIG_DIR "${./config}"
22 SetEnv SPIP_VAR_DIR "${app.varDir}"
23 SetEnv SPIP_SITE "chloe-${app.environment}"
24 SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu"
25 SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu"
26 SetEnv SPIP_LDAP_SEARCH_DN "${ccfg.ldap.dn}"
27 SetEnv SPIP_LDAP_SEARCH_PW "${ccfg.ldap.password}"
28 SetEnv SPIP_LDAP_SEARCH "${ccfg.ldap.filter}"
29 SetEnv SPIP_MYSQL_HOST "${ccfg.mysql.host}"
30 SetEnv SPIP_MYSQL_PORT "${ccfg.mysql.port}"
31 SetEnv SPIP_MYSQL_DB "${ccfg.mysql.database}"
32 SetEnv SPIP_MYSQL_USER "${ccfg.mysql.user}"
33 SetEnv SPIP_MYSQL_PASSWORD "${ccfg.mysql.password}"
34 '';
35 };
f8026b6e
IB
36 services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
37
d3452fc5
IB
38 systemd.services.phpfpm-chloe_production.after = lib.mkAfter [ "mysql.service" ];
39 systemd.services.phpfpm-chloe_production.wants = [ "mysql.service" ];
40 services.phpfpm.pools.chloe_production = {
5400b9b6
IB
41 user = config.services.httpd.Prod.user;
42 group = config.services.httpd.Prod.group;
d3452fc5
IB
43 settings = {
44 "listen.owner" = apacheUser;
45 "listen.group" = apacheGroup;
46 "php_admin_value[upload_max_filesize]" = "20M";
47 "php_admin_value[post_max_size]" = "20M";
48 # "php_admin_flag[log_errors]" = "on";
49 "php_admin_value[open_basedir]" = "${app.spipConfig}:${./config}:${app}:${app.varDir}:/tmp";
50 "php_admin_value[session.save_path]" = "${app.varDir}/phpSessions";
51 "pm" = "dynamic";
52 "pm.max_children" = "20";
53 "pm.start_servers" = "2";
54 "pm.min_spare_servers" = "1";
55 "pm.max_spare_servers" = "3";
56 };
dcac3ec7 57 phpPackage = pkgs.php72;
f40f5b23 58 };
d3452fc5
IB
59 system.activationScripts.chloe_production = {
60 deps = [ "wrappers" ];
61 text = ''
62 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local
63 install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions
64 '';
65 };
d3452fc5 66 services.websites.env.production.modules = [ "proxy_fcgi" ];
29f8cb85 67 services.websites.env.production.vhostConfs.chloe = {
f8026b6e
IB
68 certName = "chloe";
69 certMainHost = "osteopathe-cc.fr";
70 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
750fe5a4 71 root = app.webRoot;
33b5010f
IB
72 extraConfig = [
73 ''
d3452fc5
IB
74 Use Stats osteopathe-cc.fr
75
33b5010f
IB
76 RewriteEngine On
77 RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC]
78 RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L]
d3452fc5
IB
79
80 Include ${config.secrets.fullPaths."websites/chloe/production"}
81
82 RewriteEngine On
83 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
84
85 <FilesMatch "\.php$">
86 SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_production.socket}|fcgi://localhost"
87 </FilesMatch>
88
750fe5a4 89 <Directory ${app.webRoot}>
d3452fc5
IB
90 DirectoryIndex index.php index.htm index.html
91 Options -Indexes +FollowSymLinks +MultiViews +Includes
750fe5a4 92 Include ${app.webRoot}/htaccess.txt
d3452fc5
IB
93
94 AllowOverride AuthConfig FileInfo Limit
95 Require all granted
96 </Directory>
97
750fe5a4 98 <DirectoryMatch "${app.webRoot}/squelettes">
d3452fc5
IB
99 Require all denied
100 </DirectoryMatch>
101
102 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
103 Require all denied
104 </FilesMatch>
33b5010f 105 ''
33b5010f 106 ];
f8026b6e 107 };
29f8cb85 108 services.websites.env.production.watchPaths = [
d3452fc5 109 config.secrets.fullPaths."websites/chloe/production"
17f6eae9 110 ];
f8026b6e
IB
111 };
112}