1 { lib, pkgs, config, ... }:
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";
11 cfg = config.myServices.websites.chloe.production;
13 options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production";
15 config = lib.mkIf cfg.enable {
16 services.duplyBackup.profiles.chloe_production.rootDir = app.varDir;
17 services.duplyBackup.profiles.chloe_production.remotes = ["eriomem" "ovh"];
18 secrets.keys."websites/chloe/production" = {
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}"
38 services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ];
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 = {
43 user = config.services.httpd.Prod.user;
44 group = config.services.httpd.Prod.group;
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";
54 "pm.max_children" = "20";
55 "pm.start_servers" = "2";
56 "pm.min_spare_servers" = "1";
57 "pm.max_spare_servers" = "3";
59 phpPackage = pkgs.php72;
61 system.activationScripts.chloe_production = {
62 deps = [ "wrappers" ];
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
68 services.websites.env.production.modules = [ "proxy_fcgi" ];
69 services.websites.env.production.vhostConfs.chloe = {
71 certMainHost = "osteopathe-cc.fr";
72 hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ];
76 Use Stats osteopathe-cc.fr
79 RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC]
80 RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L]
82 Include ${config.secrets.fullPaths."websites/chloe/production"}
85 RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1
88 SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_production.socket}|fcgi://localhost"
91 <Directory ${app.webRoot}>
92 DirectoryIndex index.php index.htm index.html
93 Options -Indexes +FollowSymLinks +MultiViews +Includes
94 Include ${app.webRoot}/htaccess.txt
96 AllowOverride AuthConfig FileInfo Limit
100 <DirectoryMatch "${app.webRoot}/squelettes">
104 <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$">
110 services.websites.env.production.watchPaths = [
111 config.secrets.fullPaths."websites/chloe/production"