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