]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/ressourcerie_banon/production.nix
Add files for ressourcerie
[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" = "ondemand";
29 "pm.max_children" = "5";
30 "pm.process_idle_timeout" = "60";
31
32 "php_admin_value[open_basedir]" = "/var/lib/php/sessions/ressourcerie_banon:${varDir}:/tmp";
33 "php_admin_value[session.save_path]" = "/var/lib/php/sessions/ressourcerie_banon";
34 };
35 phpOptions = config.services.phpfpm.phpOptions + ''
36 disable_functions = "mail"
37 '';
38 phpPackage = pkgs.php72;
39 };
40 services.websites.env.production.modules = [ "proxy_fcgi" ];
41 services.websites.env.production.vhostConfs.ressourcerie_banon = {
42 certName = "ressourcerie_banon";
43 certMainHost = "ressourcerie-banon.org";
44 hosts = ["ressourcerie-banon.org" "www.ressourcerie-banon.org" "ressourcerie-sault.org" "www.ressourcerie-sault.org" "le-garage-autonome.org"
45 "www.le-garage-autonome.org"];
46 root = varDir;
47 extraConfig = [
48 ''
49 Use Stats ressourcerie-banon.org
50
51 RewriteEngine on
52 RewriteCond "%{HTTP_HOST}" "!^ressourcerie-banon\.org$" [NC]
53 RewriteRule ^(.+)$ https://ressourcerie-banon.org$1 [R=302,L]
54
55 <FilesMatch "\.php$">
56 SetHandler "proxy:unix:${config.services.phpfpm.pools.ressourcerie_banon.socket}|fcgi://localhost"
57 </FilesMatch>
58
59 <Directory ${varDir}>
60 DirectoryIndex index.php index.htm index.html
61 Options Indexes FollowSymLinks MultiViews Includes
62 AllowOverride all
63 Require all granted
64 </Directory>
65 ''
66 ];
67 };
68 };
69 }
70