]>
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 | |
1a718805 | 18 | secrets.keys = [{ |
d3452fc5 IB |
19 | dest = "websites/jerome/naturaloutil"; |
20 | user = apacheUser; | |
21 | group = apacheGroup; | |
85f5ed68 | 22 | permissions = "0400"; |
60dbbd12 | 23 | text = '' |
d578d270 IB |
24 | <?php |
25 | $mysql_user = '${env.mysql.user}' ; | |
26 | $mysql_server = '${env.mysql.host}' ; | |
ab8f306d | 27 | $mysql_base = '${env.mysql.database}' ; |
d578d270 IB |
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 | ?> | |
60dbbd12 | 37 | ''; |
1b3154e4 | 38 | }]; |
d3452fc5 | 39 | system.activationScripts.jerome_naturaloutil = { |
4288c2f2 IB |
40 | deps = [ "httpd" ]; |
41 | text = '' | |
d3452fc5 | 42 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/jerome_naturaloutil |
4288c2f2 IB |
43 | ''; |
44 | }; | |
d3452fc5 IB |
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; | |
5400b9b6 | 50 | settings = { |
d3452fc5 IB |
51 | "listen.owner" = apacheUser; |
52 | "listen.group" = apacheGroup; | |
d578d270 | 53 | |
5400b9b6 IB |
54 | "pm" = "ondemand"; |
55 | "pm.max_children" = "5"; | |
56 | "pm.process_idle_timeout" = "60"; | |
d578d270 | 57 | |
d3452fc5 IB |
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"; | |
5400b9b6 IB |
60 | }; |
61 | phpEnv = { | |
d3452fc5 | 62 | BDD_CONNECT = secretsPath; |
5400b9b6 | 63 | }; |
dcac3ec7 | 64 | phpPackage = pkgs.php72; |
f40f5b23 | 65 | }; |
29f8cb85 | 66 | services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; |
d3452fc5 IB |
67 | services.websites.env.production.vhostConfs.jerome_naturaloutil = { |
68 | certName = "jerome"; | |
7df420c2 IB |
69 | certMainHost = "naturaloutil.immae.eu"; |
70 | hosts = ["naturaloutil.immae.eu" ]; | |
71 | root = varDir; | |
72 | extraConfig = [ | |
5400b9b6 | 73 | (adminer.apache.vhostConf null) |
d578d270 IB |
74 | '' |
75 | Use Stats naturaloutil.immae.eu | |
76 | ServerAdmin ${env.server_admin} | |
77 | ErrorLog "${varDir}/logs/error_log" | |
78 | CustomLog "${varDir}/logs/access_log" combined | |
79 | ||
80 | <FilesMatch "\.php$"> | |
d3452fc5 | 81 | SetHandler "proxy:unix:${config.services.phpfpm.pools.jerome_naturaloutil.socket}|fcgi://localhost" |
d578d270 IB |
82 | </FilesMatch> |
83 | ||
84 | <Directory ${varDir}/logs> | |
85 | AllowOverride None | |
86 | Require all denied | |
87 | </Directory> | |
88 | <Directory ${varDir}> | |
89 | DirectoryIndex index.php index.htm index.html | |
90 | Options Indexes FollowSymLinks MultiViews Includes | |
91 | AllowOverride None | |
92 | Require all granted | |
93 | </Directory> | |
94 | '' | |
95 | ]; | |
96 | }; | |
97 | }; | |
98 | } |