]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
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"; | |
10 | }; | |
11 | cfg = config.myServices.websites.chloe.production; | |
12 | in { | |
13 | options.myServices.websites.chloe.production.enable = lib.mkEnableOption "enable Chloe's website in production"; | |
14 | ||
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" = { | |
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 | }; | |
38 | services.webstats.sites = [ { name = "osteopathe-cc.fr"; } ]; | |
39 | ||
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; | |
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 | }; | |
59 | phpPackage = pkgs.php72; | |
60 | }; | |
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 | }; | |
68 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | |
69 | services.websites.env.production.vhostConfs.chloe = { | |
70 | certName = "chloe"; | |
71 | certMainHost = "osteopathe-cc.fr"; | |
72 | hosts = ["osteopathe-cc.fr" "www.osteopathe-cc.fr" ]; | |
73 | root = app.webRoot; | |
74 | extraConfig = [ | |
75 | '' | |
76 | Use Stats osteopathe-cc.fr | |
77 | ||
78 | RewriteEngine On | |
79 | RewriteCond "%{HTTP_HOST}" "!^www\.osteopathe-cc\.fr$" [NC] | |
80 | RewriteRule ^(.+)$ https://www.osteopathe-cc.fr$1 [R=302,L] | |
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 | ||
91 | <Directory ${app.webRoot}> | |
92 | DirectoryIndex index.php index.htm index.html | |
93 | Options -Indexes +FollowSymLinks +MultiViews +Includes | |
94 | Include ${app.webRoot}/htaccess.txt | |
95 | ||
96 | AllowOverride AuthConfig FileInfo Limit | |
97 | Require all granted | |
98 | </Directory> | |
99 | ||
100 | <DirectoryMatch "${app.webRoot}/squelettes"> | |
101 | Require all denied | |
102 | </DirectoryMatch> | |
103 | ||
104 | <FilesMatch "(.htaccess|rewrite-rules|.gitignore)$"> | |
105 | Require all denied | |
106 | </FilesMatch> | |
107 | '' | |
108 | ]; | |
109 | }; | |
110 | services.websites.env.production.watchPaths = [ | |
111 | config.secrets.fullPaths."websites/chloe/production" | |
112 | ]; | |
113 | }; | |
114 | } |