]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/patrick_fodella/ecolyeu.nix
Migrate php sessions to redis
[perso/Immae/Config/Nix.git] / modules / private / websites / patrick_fodella / ecolyeu.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.patrick_fodella.ecolyeu;
4 varDir = "/var/lib/ftp/patrick_fodella/ecolyeu_pessicart";
5 apacheUser = config.services.httpd.Prod.user;
6 apacheGroup = config.services.httpd.Prod.group;
7 in {
8 options.myServices.websites.patrick_fodella.ecolyeu.enable = lib.mkEnableOption "enable Patrick Fodella Ecolyeu's website";
9
10 config = lib.mkIf cfg.enable {
11 services.webstats.sites = [ { name = "ecolyeu-pessicart-nice.fr"; } ];
12
13 systemd.services.phpfpm-patrick_fodella_ecolyeu.after = lib.mkAfter [ "mysql.service" ];
14 systemd.services.phpfpm-patrick_fodella_ecolyeu.wants = [ "mysql.service" ];
15 services.phpfpm.pools.patrick_fodella_ecolyeu = {
16 user = apacheUser;
17 group = apacheGroup;
18 settings = {
19 "listen.owner" = apacheUser;
20 "listen.group" = apacheGroup;
21
22 "pm" = "dynamic";
23 "pm.max_children" = "20";
24 "pm.start_servers" = "2";
25 "pm.min_spare_servers" = "1";
26 "pm.max_spare_servers" = "3";
27
28 "php_admin_value[open_basedir]" = "${varDir}:/tmp";
29 "php_admin_value[session.save_handler]" = "redis";
30 "php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=PatrickFodella:Altermondia:'";
31 };
32 phpOptions = config.services.phpfpm.phpOptions + ''
33 disable_functions = "mail"
34 '';
35 phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]);
36 };
37 services.websites.env.production.modules = [ "proxy_fcgi" ];
38 services.websites.env.production.vhostConfs.patrick_fodella_ecolyeu = {
39 certName = "patrick_fodella";
40 certMainHost = "ecolyeu-pessicart-nice.fr";
41 hosts = ["ecolyeu-pessicart-nice.fr" "www.ecolyeu-pessicart-nice.fr" ];
42 root = varDir;
43 extraConfig = [
44 ''
45 Use Stats ecolyeu-pessicart-nice.fr
46
47 RewriteEngine on
48 RewriteCond "%{HTTP_HOST}" "!^www\.ecolyeu-pessicart-nice\.fr$" [NC]
49 RewriteRule ^(.+)$ https://www.ecolyeu-pessicart-nice.fr$1 [R=302,L]
50
51 <FilesMatch "\.php$">
52 SetHandler "proxy:unix:${config.services.phpfpm.pools.patrick_fodella_ecolyeu.socket}|fcgi://localhost"
53 </FilesMatch>
54
55 <Location /xmlrpc.php>
56 AllowOverride None
57 Require all denied
58 </Location>
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 }