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