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