]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
d578d270 | 2 | let |
f8026b6e IB |
3 | adminer = pkgs.callPackage ../commons/adminer.nix {}; |
4 | cfg = config.myServices.websites.naturaloutil.production; | |
5 | varDir = "/var/lib/ftp/jerome"; | |
ab8f306d | 6 | env = config.myEnv.websites.jerome; |
d578d270 | 7 | in { |
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}' ; | |
ab8f306d | 24 | $mysql_base = '${env.mysql.database}' ; |
d578d270 IB |
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 | }]; |
4288c2f2 IB |
36 | system.activationScripts.naturaloutil = { |
37 | deps = [ "httpd" ]; | |
38 | text = '' | |
39 | install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/naturaloutil | |
40 | ''; | |
41 | }; | |
f40f5b23 IB |
42 | systemd.services.phpfpm-jerome.after = lib.mkAfter [ "mysql.service" ]; |
43 | systemd.services.phpfpm-jerome.wants = [ "mysql.service" ]; | |
44 | services.phpfpm.pools.jerome = { | |
45 | listen = "/run/phpfpm/naturaloutil.sock"; | |
46 | extraConfig = '' | |
47 | user = wwwrun | |
48 | group = wwwrun | |
49 | listen.owner = wwwrun | |
50 | listen.group = wwwrun | |
d578d270 | 51 | |
f40f5b23 IB |
52 | pm = ondemand |
53 | pm.max_children = 5 | |
54 | pm.process_idle_timeout = 60 | |
d578d270 | 55 | |
f40f5b23 | 56 | env[BDD_CONNECT] = "/var/secrets/webapps/prod-naturaloutil" |
4288c2f2 IB |
57 | php_admin_value[open_basedir] = "/var/lib/php/sessions/naturaloutil:/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp" |
58 | php_admin_value[session.save_path] = "/var/lib/php/sessions/naturaloutil" | |
f40f5b23 IB |
59 | ''; |
60 | phpOptions = config.services.phpfpm.phpOptions + '' | |
61 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | |
62 | ''; | |
63 | }; | |
29f8cb85 IB |
64 | services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; |
65 | services.websites.env.production.vhostConfs.naturaloutil = { | |
7df420c2 IB |
66 | certName = "naturaloutil"; |
67 | certMainHost = "naturaloutil.immae.eu"; | |
68 | hosts = ["naturaloutil.immae.eu" ]; | |
69 | root = varDir; | |
70 | extraConfig = [ | |
d578d270 IB |
71 | adminer.apache.vhostConf |
72 | '' | |
73 | Use Stats naturaloutil.immae.eu | |
74 | ServerAdmin ${env.server_admin} | |
75 | ErrorLog "${varDir}/logs/error_log" | |
76 | CustomLog "${varDir}/logs/access_log" combined | |
77 | ||
78 | <FilesMatch "\.php$"> | |
79 | SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost" | |
80 | </FilesMatch> | |
81 | ||
82 | <Directory ${varDir}/logs> | |
83 | AllowOverride None | |
84 | Require all denied | |
85 | </Directory> | |
86 | <Directory ${varDir}> | |
87 | DirectoryIndex index.php index.htm index.html | |
88 | Options Indexes FollowSymLinks MultiViews Includes | |
89 | AllowOverride None | |
90 | Require all granted | |
91 | </Directory> | |
92 | '' | |
93 | ]; | |
94 | }; | |
95 | }; | |
96 | } |