]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; }; | |
4 | cfg = config.myServices.websites.jerome.naturaloutil; | |
5 | varDir = "/var/lib/ftp/jerome"; | |
6 | env = config.myEnv.websites.jerome; | |
7 | apacheUser = config.services.httpd.Prod.user; | |
8 | apacheGroup = config.services.httpd.Prod.group; | |
9 | secretsPath = config.secrets.fullPaths."websites/jerome/naturaloutil"; | |
10 | in { | |
11 | options.myServices.websites.jerome.naturaloutil.enable = lib.mkEnableOption "enable Jerome Naturaloutil's website"; | |
12 | ||
13 | config = lib.mkIf cfg.enable { | |
14 | services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ]; | |
15 | ||
16 | security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null; | |
17 | ||
18 | secrets.keys = [{ | |
19 | dest = "websites/jerome/naturaloutil"; | |
20 | user = apacheUser; | |
21 | group = apacheGroup; | |
22 | permissions = "0400"; | |
23 | text = '' | |
24 | <?php | |
25 | $mysql_user = '${env.mysql.user}' ; | |
26 | $mysql_server = '${env.mysql.host}' ; | |
27 | $mysql_base = '${env.mysql.database}' ; | |
28 | $mysql_password = '${env.mysql.password}' ; | |
29 | //connect to db | |
30 | $db = mysqli_init(); | |
31 | ${if env.mysql.host != "localhost" then '' | |
32 | mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); | |
33 | $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL); | |
34 | '' else ""} | |
35 | $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password); | |
36 | ?> | |
37 | ''; | |
38 | }]; | |
39 | system.activationScripts.jerome_naturaloutil = { | |
40 | deps = [ "httpd" ]; | |
41 | text = '' | |
42 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/jerome_naturaloutil | |
43 | ''; | |
44 | }; | |
45 | systemd.services.phpfpm-jerome_naturaloutil.after = lib.mkAfter [ "mysql.service" ]; | |
46 | systemd.services.phpfpm-jerome_naturaloutil.wants = [ "mysql.service" ]; | |
47 | services.phpfpm.pools.jerome_naturaloutil = { | |
48 | user = apacheUser; | |
49 | group = apacheGroup; | |
50 | settings = { | |
51 | "listen.owner" = apacheUser; | |
52 | "listen.group" = apacheGroup; | |
53 | ||
54 | "pm" = "ondemand"; | |
55 | "pm.max_children" = "5"; | |
56 | "pm.process_idle_timeout" = "60"; | |
57 | ||
58 | "php_admin_value[open_basedir]" = "/var/lib/php/sessions/jerome_naturaloutil:${secretsPath}:${varDir}:/tmp"; | |
59 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/jerome_naturaloutil"; | |
60 | }; | |
61 | phpEnv = { | |
62 | BDD_CONNECT = secretsPath; | |
63 | }; | |
64 | phpOptions = config.services.phpfpm.phpOptions + '' | |
65 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | |
66 | ''; | |
67 | }; | |
68 | services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; | |
69 | services.websites.env.production.vhostConfs.jerome_naturaloutil = { | |
70 | certName = "jerome"; | |
71 | certMainHost = "naturaloutil.immae.eu"; | |
72 | hosts = ["naturaloutil.immae.eu" ]; | |
73 | root = varDir; | |
74 | extraConfig = [ | |
75 | (adminer.apache.vhostConf null) | |
76 | '' | |
77 | Use Stats naturaloutil.immae.eu | |
78 | ServerAdmin ${env.server_admin} | |
79 | ErrorLog "${varDir}/logs/error_log" | |
80 | CustomLog "${varDir}/logs/access_log" combined | |
81 | ||
82 | <FilesMatch "\.php$"> | |
83 | SetHandler "proxy:unix:${config.services.phpfpm.pools.jerome_naturaloutil.socket}|fcgi://localhost" | |
84 | </FilesMatch> | |
85 | ||
86 | <Directory ${varDir}/logs> | |
87 | AllowOverride None | |
88 | Require all denied | |
89 | </Directory> | |
90 | <Directory ${varDir}> | |
91 | DirectoryIndex index.php index.htm index.html | |
92 | Options Indexes FollowSymLinks MultiViews Includes | |
93 | AllowOverride None | |
94 | Require all granted | |
95 | </Directory> | |
96 | '' | |
97 | ]; | |
98 | }; | |
99 | }; | |
100 | } |