]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/naturaloutil/production.nix
Move personal websites to modules
[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
IB
35 }];
36 services.myPhpfpm.serviceDependencies.jerome = [ "mysql.service" ];
60dbbd12 37 services.myPhpfpm.poolConfigs.jerome = ''
d578d270
IB
38 listen = /run/phpfpm/naturaloutil.sock
39 user = wwwrun
40 group = wwwrun
41 listen.owner = wwwrun
42 listen.group = wwwrun
43
44 pm = ondemand
45 pm.max_children = 5
46 pm.process_idle_timeout = 60
47
1b3154e4
IB
48 env[BDD_CONNECT] = "/var/secrets/webapps/prod-naturaloutil"
49 php_admin_value[open_basedir] = "/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp"
d578d270
IB
50 '';
51 services.myPhpfpm.poolPhpConfigs.jerome = ''
52 extension=${pkgs.php}/lib/php/extensions/mysqli.so
53 '';
daf64e3f
IB
54 services.websites.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ];
55 services.websites.production.vhostConfs.naturaloutil = {
7df420c2
IB
56 certName = "naturaloutil";
57 certMainHost = "naturaloutil.immae.eu";
58 hosts = ["naturaloutil.immae.eu" ];
59 root = varDir;
60 extraConfig = [
d578d270
IB
61 adminer.apache.vhostConf
62 ''
63 Use Stats naturaloutil.immae.eu
64 ServerAdmin ${env.server_admin}
65 ErrorLog "${varDir}/logs/error_log"
66 CustomLog "${varDir}/logs/access_log" combined
67
68 <FilesMatch "\.php$">
69 SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost"
70 </FilesMatch>
71
72 <Directory ${varDir}/logs>
73 AllowOverride None
74 Require all denied
75 </Directory>
76 <Directory ${varDir}>
77 DirectoryIndex index.php index.htm index.html
78 Options Indexes FollowSymLinks MultiViews Includes
79 AllowOverride None
80 Require all granted
81 </Directory>
82 ''
83 ];
84 };
85 };
86}