]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/ressourcerie_banon/production.nix
Fix php-fpm that were on-demand instead of dynamic
[perso/Immae/Config/Nix.git] / modules / private / websites / ressourcerie_banon / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.ressourcerie_banon.production;
4 varDir = "/var/lib/ftp/ressourcerie_banon";
5 apacheUser = config.services.httpd.Prod.user;
6 apacheGroup = config.services.httpd.Prod.group;
7 in {
8 options.myServices.websites.ressourcerie_banon.production.enable = lib.mkEnableOption "enable Ressourcerie Banon's website";
9
10 config = lib.mkIf cfg.enable {
11 services.webstats.sites = [ { name = "ressourcerie-banon.org"; } ];
12
13 system.activationScripts.ressourcerie_banon = {
14 deps = [ "httpd" ];
15 text = ''
16 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/ressourcerie_banon
17 '';
18 };
19 systemd.services.phpfpm-ressourcerie_banon.after = lib.mkAfter [ "mysql.service" ];
20 systemd.services.phpfpm-ressourcerie_banon.wants = [ "mysql.service" ];
21 services.phpfpm.pools.ressourcerie_banon = {
22 user = apacheUser;
23 group = apacheGroup;
24 settings = {
25 "listen.owner" = apacheUser;
26 "listen.group" = apacheGroup;
27
28 "pm" = "dynamic";
29 "pm.max_children" = "20";
30 "pm.start_servers" = "2";
31 "pm.min_spare_servers" = "1";
32 "pm.max_spare_servers" = "3";
33
34 "php_admin_value[open_basedir]" = "/var/lib/php/sessions/ressourcerie_banon:${varDir}:/tmp";
35 "php_admin_value[session.save_path]" = "/var/lib/php/sessions/ressourcerie_banon";
36 };
37 phpOptions = config.services.phpfpm.phpOptions + ''
38 disable_functions = "mail"
39 '';
40 phpPackage = pkgs.php72;
41 };
42 services.websites.env.production.modules = [ "proxy_fcgi" ];
43 services.websites.env.production.vhostConfs.ressourcerie_banon = {
44 certName = "ressourcerie_banon";
45 certMainHost = "ressourcerie-banon.org";
46 hosts = ["ressourcerie-banon.org" "www.ressourcerie-banon.org" "le-garage-autonome.org"
47 "www.le-garage-autonome.org"];
48 root = varDir;
49 extraConfig = [
50 ''
51 Use Stats ressourcerie-banon.org
52
53 RewriteEngine on
54 RewriteCond "%{HTTP_HOST}" "!^ressourcerie-banon\.org$" [NC]
55 RewriteRule ^(.+)$ https://ressourcerie-banon.org$1 [R=302,L]
56
57 <FilesMatch "\.php$">
58 SetHandler "proxy:unix:${config.services.phpfpm.pools.ressourcerie_banon.socket}|fcgi://localhost"
59 </FilesMatch>
60
61 <Directory ${varDir}>
62 DirectoryIndex index.php index.htm index.html
63 Options Indexes FollowSymLinks MultiViews Includes
64 AllowOverride all
65 Require all granted
66 </Directory>
67 ''
68 ];
69 };
70 };
71 }
72