]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/naturaloutil/production.nix
Replace myPhpfpm with correct overrides
[perso/Immae/Config/Nix.git] / modules / private / websites / naturaloutil / production.nix
CommitLineData
8a964143 1{ lib, pkgs, config, myconfig, ... }:
d578d270 2let
f8026b6e
IB
3 adminer = pkgs.callPackage ../commons/adminer.nix {};
4 cfg = config.myServices.websites.naturaloutil.production;
5 varDir = "/var/lib/ftp/jerome";
6 env = myconfig.env.websites.jerome;
d578d270 7in {
f8026b6e 8 options.myServices.websites.naturaloutil.production.enable = lib.mkEnableOption "enable Naturaloutil's website";
d578d270 9
f8026b6e 10 config = lib.mkIf cfg.enable {
9eae2b47 11 services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ];
d578d270
IB
12
13 security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null;
d578d270 14
1a718805 15 secrets.keys = [{
1b3154e4 16 dest = "webapps/prod-naturaloutil";
60dbbd12
IB
17 user = "wwwrun";
18 group = "wwwrun";
85f5ed68 19 permissions = "0400";
60dbbd12 20 text = ''
d578d270
IB
21 <?php
22 $mysql_user = '${env.mysql.user}' ;
23 $mysql_server = '${env.mysql.host}' ;
24 $mysql_base = '${env.mysql.name}' ;
25 $mysql_password = '${env.mysql.password}' ;
26 //connect to db
27 $db = mysqli_init();
28 ${if env.mysql.host != "localhost" then ''
29 mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true);
30 $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL);
31 '' else ""}
32 $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password);
33 ?>
60dbbd12 34 '';
1b3154e4 35 }];
f40f5b23
IB
36 systemd.services.phpfpm-jerome.after = lib.mkAfter [ "mysql.service" ];
37 systemd.services.phpfpm-jerome.wants = [ "mysql.service" ];
38 services.phpfpm.pools.jerome = {
39 listen = "/run/phpfpm/naturaloutil.sock";
40 extraConfig = ''
41 user = wwwrun
42 group = wwwrun
43 listen.owner = wwwrun
44 listen.group = wwwrun
d578d270 45
f40f5b23
IB
46 pm = ondemand
47 pm.max_children = 5
48 pm.process_idle_timeout = 60
d578d270 49
f40f5b23
IB
50 env[BDD_CONNECT] = "/var/secrets/webapps/prod-naturaloutil"
51 php_admin_value[open_basedir] = "/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp"
52 '';
53 phpOptions = config.services.phpfpm.phpOptions + ''
54 extension=${pkgs.php}/lib/php/extensions/mysqli.so
55 '';
56 };
daf64e3f
IB
57 services.websites.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
58 services.websites.production.vhostConfs.naturaloutil = {
7df420c2
IB
59 certName = "naturaloutil";
60 certMainHost = "naturaloutil.immae.eu";
61 hosts = ["naturaloutil.immae.eu" ];
62 root = varDir;
63 extraConfig = [
d578d270
IB
64 adminer.apache.vhostConf
65 ''
66 Use Stats naturaloutil.immae.eu
67 ServerAdmin ${env.server_admin}
68 ErrorLog "${varDir}/logs/error_log"
69 CustomLog "${varDir}/logs/access_log" combined
70
71 <FilesMatch "\.php$">
72 SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost"
73 </FilesMatch>
74
75 <Directory ${varDir}/logs>
76 AllowOverride None
77 Require all denied
78 </Directory>
79 <Directory ${varDir}>
80 DirectoryIndex index.php index.htm index.html
81 Options Indexes FollowSymLinks MultiViews Includes
82 AllowOverride None
83 Require all granted
84 </Directory>
85 ''
86 ];
87 };
88 };
89}