]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
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 | 11 | cfg = config.myServices.websites.chloe.production; |
d3452fc5 | 12 | webappdir = config.services.websites.webappDirsPaths.chloe_production; |
f8026b6e IB |
13 | in { |
14 | options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production"; | |
15 | ||
16 | config = lib.mkIf cfg.enable { | |
d3452fc5 | 17 | services.duplyBackup.profiles.chloe_production.rootDir = app.varDir; |
5a61f6ad | 18 | services.duplyBackup.profiles.chloe_production.remotes = ["eriomem" "ovh"]; |
d3452fc5 IB |
19 | secrets.keys = [ |
20 | { | |
21 | dest = "websites/chloe/production"; | |
22 | user = apacheUser; | |
23 | group = apacheGroup; | |
24 | permissions = "0400"; | |
25 | text = '' | |
26 | SetEnv SPIP_CONFIG_DIR "${./config}" | |
27 | SetEnv SPIP_VAR_DIR "${app.varDir}" | |
28 | SetEnv SPIP_SITE "chloe-${app.environment}" | |
29 | SetEnv SPIP_LDAP_BASE "dc=immae,dc=eu" | |
30 | SetEnv SPIP_LDAP_HOST "ldaps://ldap.immae.eu" | |
31 | SetEnv SPIP_LDAP_SEARCH_DN "${ccfg.ldap.dn}" | |
32 | SetEnv SPIP_LDAP_SEARCH_PW "${ccfg.ldap.password}" | |
33 | SetEnv SPIP_LDAP_SEARCH "${ccfg.ldap.filter}" | |
34 | SetEnv SPIP_MYSQL_HOST "${ccfg.mysql.host}" | |
35 | SetEnv SPIP_MYSQL_PORT "${ccfg.mysql.port}" | |
36 | SetEnv SPIP_MYSQL_DB "${ccfg.mysql.database}" | |
37 | SetEnv SPIP_MYSQL_USER "${ccfg.mysql.user}" | |
38 | SetEnv SPIP_MYSQL_PASSWORD "${ccfg.mysql.password}" | |
39 | ''; | |
40 | } | |
41 | ]; | |
f8026b6e IB |
42 | services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ]; |
43 | ||
d3452fc5 IB |
44 | systemd.services.phpfpm-chloe_production.after = lib.mkAfter [ "mysql.service" ]; |
45 | systemd.services.phpfpm-chloe_production.wants = [ "mysql.service" ]; | |
46 | services.phpfpm.pools.chloe_production = { | |
5400b9b6 IB |
47 | user = config.services.httpd.Prod.user; |
48 | group = config.services.httpd.Prod.group; | |
d3452fc5 IB |
49 | settings = { |
50 | "listen.owner" = apacheUser; | |
51 | "listen.group" = apacheGroup; | |
52 | "php_admin_value[upload_max_filesize]" = "20M"; | |
53 | "php_admin_value[post_max_size]" = "20M"; | |
54 | # "php_admin_flag[log_errors]" = "on"; | |
55 | "php_admin_value[open_basedir]" = "${app.spipConfig}:${./config}:${app}:${app.varDir}:/tmp"; | |
56 | "php_admin_value[session.save_path]" = "${app.varDir}/phpSessions"; | |
57 | "pm" = "dynamic"; | |
58 | "pm.max_children" = "20"; | |
59 | "pm.start_servers" = "2"; | |
60 | "pm.min_spare_servers" = "1"; | |
61 | "pm.max_spare_servers" = "3"; | |
62 | }; | |
dcac3ec7 | 63 | phpPackage = pkgs.php72; |
f40f5b23 | 64 | }; |
d3452fc5 IB |
65 | system.activationScripts.chloe_production = { |
66 | deps = [ "wrappers" ]; | |
67 | text = '' | |
68 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} ${app.varDir}/IMG ${app.varDir}/tmp ${app.varDir}/local | |
69 | install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions | |
70 | ''; | |
71 | }; | |
72 | services.websites.webappDirs.chloe_production = app.webRoot; | |
73 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | |
29f8cb85 | 74 | services.websites.env.production.vhostConfs.chloe = { |
f8026b6e IB |
75 | certName = "chloe"; |
76 | certMainHost = "osteopathe-cc.fr"; | |
77 | hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ]; | |
d3452fc5 | 78 | root = webappdir; |
33b5010f IB |
79 | extraConfig = [ |
80 | '' | |
d3452fc5 IB |
81 | Use Stats osteopathe-cc.fr |
82 | ||
33b5010f IB |
83 | RewriteEngine On |
84 | RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC] | |
85 | RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L] | |
d3452fc5 IB |
86 | |
87 | Include ${config.secrets.fullPaths."websites/chloe/production"} | |
88 | ||
89 | RewriteEngine On | |
90 | RewriteRule ^/news.rss /spip.php?page=backend&id_rubrique=1 | |
91 | ||
92 | <FilesMatch "\.php$"> | |
93 | SetHandler "proxy:unix:${config.services.phpfpm.pools.chloe_production.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> | |
33b5010f | 112 | '' |
33b5010f | 113 | ]; |
f8026b6e | 114 | }; |
29f8cb85 | 115 | services.websites.env.production.watchPaths = [ |
d3452fc5 | 116 | config.secrets.fullPaths."websites/chloe/production" |
17f6eae9 | 117 | ]; |
f8026b6e IB |
118 | }; |
119 | } |