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