]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/patrick_fodella/production.nix
Add Patrick Fodella’s website
[perso/Immae/Config/Nix.git] / modules / private / websites / patrick_fodella / production.nix
1 { lib, pkgs, config, ... }:
2 let
3 cfg = config.myServices.websites.patrick_fodella.production;
4 varDir = "/var/lib/ftp/patrick_fodella";
5 apacheUser = config.services.httpd.Prod.user;
6 apacheGroup = config.services.httpd.Prod.group;
7 in {
8 options.myServices.websites.patrick_fodella.production.enable = lib.mkEnableOption "enable Patrick Fodella's website";
9
10 config = lib.mkIf cfg.enable {
11 services.webstats.sites = [ { name = "ecolyeu-pessicart-nice.fr"; } ];
12
13 system.activationScripts.patrick_fodella = {
14 deps = [ "httpd" ];
15 text = ''
16 install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/patrick_fodella
17 '';
18 };
19 systemd.services.phpfpm-patrick_fodella.after = lib.mkAfter [ "mysql.service" ];
20 systemd.services.phpfpm-patrick_fodella.wants = [ "mysql.service" ];
21 services.phpfpm.pools.patrick_fodella = {
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/patrick_fodella:${varDir}:/tmp";
33 "php_admin_value[session.save_path]" = "/var/lib/php/sessions/patrick_fodella";
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.patrick_fodella = {
42 certName = "patrick_fodella";
43 certMainHost = "ecolyeu-pessicart-nice.fr";
44 hosts = ["ecolyeu-pessicart-nice.fr" "www.ecolyeu-pessicart-nice.fr" ];
45 root = varDir;
46 extraConfig = [
47 ''
48 Use Stats ecolyeu-pessicart-nice.fr
49
50 RewriteEngine on
51 RewriteCond "%{HTTP_HOST}" "!^www\.ecolyeu-pessicart-nice\.fr$" [NC]
52 RewriteRule ^(.+)$ https://www.ecolyeu-pessicart-nice.fr$1 [R=302,L]
53
54 <FilesMatch "\.php$">
55 SetHandler "proxy:unix:${config.services.phpfpm.pools.patrick_fodella.socket}|fcgi://localhost"
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 }