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