]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/patrick_fodella/altermondia.nix
Fix patrick certificate
[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 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 = {
18 user = apacheUser;
19 group = apacheGroup;
20 settings = {
21 "listen.owner" = apacheUser;
22 "listen.group" = apacheGroup;
23
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";
29
30 "env[BIN_ENV]" = "${binEnv}/bin";
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:'";
34 };
35 phpOptions = config.services.phpfpm.phpOptions + ''
36 disable_functions = "mail"
37 '';
38 phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]);
39 };
40 services.websites.env.production.modules = [ "proxy_fcgi" ];
41 services.websites.env.production.vhostConfs.patrick_fodella_altermondia = {
42 certName = "patrick_fodella";
43 addToCerts = true;
44 certMainHost = "altermondia.org";
45 hosts = ["altermondia.org" "www.altermondia.org" ];
46 root = varDir;
47 extraConfig = [
48 ''
49 Use Stats altermondia.org
50
51 RewriteEngine on
52 RewriteCond "%{HTTP_HOST}" "!^altermondia\.org$" [NC]
53 RewriteRule ^(.+)$ https://altermondia.org$1 [R=302,L]
54
55 <FilesMatch "\.php$">
56 SetHandler "proxy:unix:${config.services.phpfpm.pools.patrick_fodella_altermondia.socket}|fcgi://localhost"
57 </FilesMatch>
58
59 <Location /xmlrpc.php>
60 AllowOverride None
61 Require all denied
62 </Location>
63 <Directory ${varDir}>
64 DirectoryIndex index.php index.htm index.html
65 Options Indexes FollowSymLinks MultiViews Includes
66 AllowOverride all
67 Require all granted
68 </Directory>
69 ''
70 ];
71 };
72 };
73 }
74