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