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